BedWars Creative
  • 📜Changelog
  • ðŸŽĻSandbox Mode
  • 🊓WorldEdit Commands
  • ðŸ›ĄïļWorldGuard System
  • 🍊BedWars Scripting
    • 🚜Services
      • ðŸŽ―AbilityService
      • ðŸ“ĢAnnouncementService
      • ðŸ§ąBlockService
      • ðŸ”ĪChatService
      • ⚔ïļCombatService
      • 🌊ïļDisasterService
      • 🊅DataStoreService
      • ðŸŠĻEntityService
      • ðŸ”ĨForgeService
      • 🏭GeneratorService
      • ðŸ‘Đ‍🚀GravityService
      • âŒĻïļInputService
      • 🎒InventoryService
      • 💎ItemService
      • 🛏ïļMatchService
      • â„đïļMessageService
      • 🎁ModelService
      • ðŸĶĪMountService
      • 🏄‍♂ïļPlayerService
      • 🏗ïļPartService
      • 🎉ParticleService
      • 👆PromptService
      • 💰ShopService
      • ðŸ“ŧSoundService
      • 🊄StatusEffectService
      • 🚁VehicleService
      • ðŸšĐTeamService
      • ðŸĨ‡UIService
    • ðŸĪEvents
      • BeforeProjectileLaunched
      • BlockPlace
      • BlockBreak
      • BedAlarmTriggered
      • ConsumeItem
      • Enchant
      • EntityDamage
      • EntityDeath
      • EntitySpawn
      • Forged
      • InventoryItemAdded
      • ItemPurchase
      • MatchStart
      • PlayerChatted
      • PlayerAdded
      • PlayerRemoving
      • PlayerDropItem
      • PlayerPickupItem
      • ProjectileLaunched
      • ProjectileHit
      • StatusEffectAdded
      • StatusEffectRemoved
      • WeaponSwing
      • TeamUpgradePurchased
      • TeamUpgradeEraPurchased
      • Telepearled
      • UseAbility
    • ðŸ“ĶObjects
      • AbilityConfig
      • Block
      • Entity
        • ImageEntity
        • KitEntity
        • CreatureEntity
      • Generator
      • Knockback
      • Leaderboard
      • MatchState
      • Model
      • ParticleEmitter
      • Part
      • Player
      • Prompt
      • ProgressBar
      • TextLabel
      • Team
    • 📚Types
      • AbilityType
      • AbilityInputType
      • CreatureType
      • DisasterType
      • EnchantType
      • ItemType
      • KitType
      • ModelType
      • MountType
      • VehicleType
      • ProjectileType
      • SoundType
      • StatusEffectType
      • TeamUpgradeEraType
      • TeamUpgradeType
      • MatchRole
    • ⚙ïļUtilities
      • require
      • math
      • pairs & ipairs
      • print & error
      • os
      • string
      • table
      • task
      • tick
      • tostring & tonumber
      • wait
Powered by GitBook
On this page
  1. BedWars Scripting
  2. Services

EntityService

Service for creating new entities.

PreviousDataStoreServiceNextForgeService

Last updated 1 year ago

Functions

getNearbyEntities(center: , radius: number): [] | nil

Returns entities contained in the radius around the center position.

spawnKitEntity(kitType: , position: ): | nil

Spawns an entity using a BedWars model at the specified position. Use the returned object to further configure the .

Example usage:

Events.MatchStart(function(event)
    -- Add a Barbarian Kit entity to the game when the match begins
    local kit = EntityService.spawnKitEntity(KitType.BARBARIAN, BlockService.getAboveRandomBlock())
    -- Give the kit entity a rageblade weapon
    kit:setHandItem(ItemType.RAGEBLADE)
    -- Gives the kit a set of Iron armor
    kit:setArmor(ItemType.IRON_HELMET)
end)

spawnCreatureEntity(creatureType: , position: , team: | nil): | nil

Spawns a using a BedWars model at the specified position. Use the optional team parameter with Skeletons or Ducks to set them to be allied with that . Use the returned object to further configure the entity.

Example usage:

Events.EntityDeath(function(event) 
    -- Only spawn a creature if the entity that died was a player 
    if (event.entity:getPlayer() == nil) then 
        return 
    end
    
    -- Only spawn a creature if this was the final kill of the player
    if not event.finalKill then
        return
    end
    
    -- Only spawn a creature if there was a killer
    if (event.killer == nil) then
        return
    end
    
    -- Only spawn a creature if the killer was a player
    if (event.killer:getPlayer() == nil) then
        return
    end
    
    local team = TeamService.getTeam(event.killer:getPlayer())
    -- Spawns a Skeleton creature allied with the killer's team
    EntityService.spawnCreatureEntity(CreatureType.SKELETON, event.killer.getPosition(), team)
end)
function chase(player, entity)
    while task.wait(0.1) do
        if not player:getEntity() then
           continue
        end
        entity:moveTo(player:getEntity():getPosition())
    end
end

Events.BlockPlace(function(event)
    if (event.blockType == ItemType.SLIME_BLOCK) then
        local entity = EntityService.spawnImageEntity("rbxassetid://11467634330", event.position + Vector3.new(0,4,0))
        entity:setCustomName("Gloop")
        task.spawn(function()
            chase(event.player, entity)
        end)
    end
end)

spawnImageEntity(image: string, position: ):

Creates an using an image at the specified position. The string for the image parameter must be a . Use the returned object to further configure the entity.

🍊
🚜
ðŸŠĻ
Vector3
Entity
KitType
Vector3
KitEntity
KitType
KitEntity
KitEntity
CreatureType
Vector3
Team
CreatureEntity
CreatureEntity
CreatureType
Team
CreatureEntity
Vector3
ImageEntity
ImageEntity
rbxassetid
ImageEntity