Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local playerBlocksPositions = {}
- local pickPositions = {
- Vector3.new(348, 66, 315),
- Vector3.new(342, 66, 315),
- Vector3.new(339, 66, 312),
- Vector3.new(345, 66, 312),
- Vector3.new(351, 66, 312),
- Vector3.new(348, 66, 309),
- Vector3.new(342, 66, 309),
- Vector3.new(351, 66, 306),
- Vector3.new(345, 66, 306),
- Vector3.new(339, 66, 306)
- }
- Events.BlockPlace(function(event)
- local player = event.player
- local position = event.position
- local blockType = event.blockType
- if not playerBlocksPositions[player.userId] then
- playerBlocksPositions[player.userId] = {}
- end
- table.insert(playerBlocksPositions[player.userId], {position = position, blockType = blockType})
- end)
- local function destroyPlayerBlocks(player)
- if playerBlocksPositions[player.userId] then
- for _, blockInfo in pairs(playerBlocksPositions[player.userId]) do
- BlockService.destroyBlock(blockInfo.position)
- end
- playerBlocksPositions[player.userId] = nil
- end
- end
- local function placeBlockAtRandomPosition()
- if #pickPositions == 0 then return end
- local randomIndex = math.random(1, #pickPositions)
- local position = table.remove(pickPositions, randomIndex)
- BlockService.placeBlock(ItemType.CLAY_RED, position)
- return position
- end
- local function checkNearbyEntitiesAbove(position)
- local checkPosition = position + Vector3.new(0, 5, 0)
- local nearbyPlayers = PlayerService.getNearbyPlayers(checkPosition, 3)
- if nearbyPlayers then
- for _, player in pairs(nearbyPlayers) do
- local entity = player:getEntity()
- if entity then
- local entityPos = entity:getPosition()
- if entityPos and (entityPos - checkPosition).Magnitude <= 3 then
- return player
- end
- end
- end
- end
- return nil
- end
- local function startBlockPlacingRoutine()
- while #pickPositions > 0 do
- local position = placeBlockAtRandomPosition()
- while true do
- task.wait(0.01)
- local player = checkNearbyEntitiesAbove(position)
- if player then
- BlockService.destroyBlock(position)
- BlockService.placeBlock(ItemType.CLAY_GREEN, position)
- destroyPlayerBlocks(player)
- break
- end
- end
- end
- end
- Events.EntityDeath(function(event)
- local player = event.entity:getPlayer()
- if player then
- if event.finalKill then
- destroyPlayerBlocks(player)
- end
- end
- end)
- task.spawn(startBlockPlacingRoutine)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement