Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local luckyBoxPick = BlockService.getAllBlocks({ItemType.CLAY_WHITE})
- if #luckyBoxPick > 0 then
- local block = luckyBoxPick[math.random(1, #luckyBoxPick)]
- local centerPosition = block.position + Vector3.new(0, 1.6, 0)
- local circleRadius = 13 -- Example radius
- local partCount = 8 + (circleRadius * 2)
- local partSize = Vector3.new(1, 0.2, 0.3)
- local spaceGap = 0.5
- for i = 1, partCount do
- local angle = (i / partCount) * math.pi * 2
- local offsetX = math.cos(angle) * (circleRadius + partSize.X / 2 + spaceGap)
- local offsetZ = math.sin(angle) * (circleRadius + partSize.X / 2 + spaceGap)
- local partPosition = centerPosition + Vector3.new(offsetX, 0, offsetZ)
- local part = PartService.createPart(ItemType.WOOL_WHITE, partPosition)
- part:setSize(partSize)
- part:setAnchored(true)
- part:setCollidable(false)
- local lookAtCFrame = CFrame.new(partPosition, centerPosition)
- part:setCFrame(lookAtCFrame)
- end
- local nearbyEntities = EntityService.getNearbyEntities(centerPosition, 10)
- if #nearbyEntities > 0 then
- local entity = nearbyEntities[1]
- local function updatePartsOrientation()
- task.spawn(function()
- while entity:isAlive() do
- local entityPos = entity:getPosition()
- for i = 1, partCount do
- local angle = (i / partCount) * math.pi * 2
- local offsetX = math.cos(angle) * (circleRadius + partSize.X / 2 + spaceGap)
- local offsetZ = math.sin(angle) * (circleRadius + partSize.X / 2 + spaceGap)
- local partPosition = centerPosition + Vector3.new(offsetX, 0, offsetZ)
- local part = PartService.getPartAt(partPosition)
- if part then
- local direction = (entityPos - partPosition).unit
- local lookAtCFrame = CFrame.new(partPosition, partPosition + direction)
- part:setCFrame(lookAtCFrame)
- end
- end
- task.wait(0)
- end
- end)
- end
- updatePartsOrientation()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement