π§±BlockService
Service for placement and removal of blocks.
-- 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
endFunctions
placeBlock(blockType: ItemType, position: Vector3): bool
getAboveRandomBlock(aboveBlockTypes: ItemType[] | nil): Vector3
destroyBlock(position: Vector3): bool
Last updated