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

BlockService

Service for placement and removal of blocks.

Example usage:

-- Replace block beneath all players with diamond blocks
while (task.wait(0)) do
    -- Loop over all players
    for i, player in pairs(PlayerService.getPlayers()) do
        -- Get player's entity
        local entity = player:getEntity()
        if (not entity) then
            continue
        end

        -- Get block beneath player
        local positionBeneath = entity:getPosition() - Vector3.new(0, 5, 0)
        local blockBeneath = BlockService.getBlockAt(positionBeneath)
        if blockBeneath then
            -- If block beneath exists then destroy it and place diamond block
            BlockService.destroyBlock(positionBeneath)
            BlockService.placeBlock(ItemType.DIAMOND_BLOCK, positionBeneath)
        end
    end
end

Functions

Placed a block at position. Returns true if block was placed.

Returns the block at the given position. Will return nil if no block exists at the position.

Returns a random position above a block. Can optionally specify a set of aboveBlockTypes to get a position only above a block of those types.

Destroys block at position. Returns true if a block was destroyed.

Returns all blocks in the world. If a set of blockTypes is supplied it will only return blocks of that type. Warning: this function is very slow, especially when you do not supply a list of blockTypes.

Returns blocks contained in a part centered at the specified center with the specified size. If a set of blockTypes is supplied, it will only return blocks of that type.

PreviousAnnouncementServiceNextChatService

Last updated 1 year ago

placeBlock(blockType: ItemType, position: ): bool

getBlockAt(position: ): | nil

getAboveRandomBlock(aboveBlockTypes: ItemType[] | nil):

destroyBlock(position: ): bool

getAllBlocks(blockTypes: [] | nil): []

getNearbyBlocks(center: , size: , blockTypes: [] | nil): [] | nil

🍊
🚜
ðŸ§ą
Vector3
Vector3
Block
Vector3
Vector3
ItemType
Block
Vector3
Vector3
ItemType
Block