Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local woolBlocks = BlockService.getAllBlocks({ ItemType.WOOL_RED })
- local radius = 25
- local angleOffset = math.rad(80)
- local partSize = Vector3.new(0.31, 0.2, 0.31)
- local rotationOffset = CFrame.Angles(0, math.rad(0.80), 0)
- local step = partSize.X
- if #woolBlocks > 0 then for _, woolBlock in pairs(woolBlocks) do local center = woolBlock.position + Vector3.new(0, 1.5, 0)
- local rightLineParts = {}
- local leftLineParts = {}
- local circleParts = {}
- local topParts = {}
- local function createPart(position, size, lookAtTarget, partList)
- local direction = (lookAtTarget - position).Unit
- local part = PartService.createPart(ItemType.CLAY_WHITE, position)
- part:setSize(size)
- part:setCFrame(CFrame.lookAt(position, position + direction) * rotationOffset)
- table.insert(partList, part)
- return part
- end
- for i = 1, math.floor(radius * 3) + 2 do
- local angleStep = (i / (radius * 3)) * math.pi * 2
- local pos = center + Vector3.new(math.cos(angleStep) * (radius + 0.3), 0, math.sin(angleStep) * (radius + 0.3))
- createPart(pos, Vector3.new(1, 0.2, 0.3), center, circleParts)
- end
- for distance = step, radius + step, step do
- for _, a in ipairs({ angleOffset, -angleOffset }) do
- local pos = center + Vector3.new(math.cos(a) * distance, 0, math.sin(a) * distance)
- local partList = (a == angleOffset) and rightLineParts or leftLineParts
- createPart(pos, partSize, center, partList)
- end
- end
- local angleFactor = math.abs(angleOffset) / math.rad(50)
- local capPartsCount = math.ceil((radius * 2) / partSize.X * angleFactor)
- for i = 0, capPartsCount do
- local t = i / capPartsCount
- local capAngle = (angleOffset * (1 - t)) + (-angleOffset * t)
- local capPos = center + Vector3.new(math.cos(capAngle) * (radius + 0.3), 0, math.sin(capAngle) * (radius + 0.3))
- createPart(capPos, partSize, center, topParts)
- end
- local newCapPartsCount = #topParts
- for i, part in ipairs(topParts) do
- local t = i / (newCapPartsCount + 1)
- local capAngle = (angleOffset * (1 - t)) + (-angleOffset * t)
- local capPos = center + Vector3.new(math.cos(capAngle) * (radius + 0.3), 0, math.sin(capAngle) * (radius + 0.3))
- part:setPosition(capPos)
- part:setCFrame(CFrame.lookAt(capPos, woolBlock.position + Vector3.new(0, 1.5, 0)) * rotationOffset)
- end
- local extraOffset = math.rad(5)
- local extraLeftCapPos = center + Vector3.new(math.cos(-angleOffset + extraOffset) * (radius + 0.3), 0, math.sin(-angleOffset + extraOffset) * (radius + 0.3))
- local extraRightCapPos = center + Vector3.new(math.cos(angleOffset - extraOffset) * (radius + 0.3), 0, math.sin(angleOffset - extraOffset) * (radius + 0.3))
- createPart(extraLeftCapPos, partSize, center, topParts)
- createPart(extraRightCapPos, partSize, center, topParts)
- task.spawn(function()
- while true do
- local nearestPlayer = nil
- local nearestDistance = radius
- local entities = EntityService.getNearbyEntities(center, radius)
- for _, entity in ipairs(entities) do
- local player = entity:getPlayer()
- if player then
- local playerPos = entity:getPosition()
- local dist = (playerPos - center).Magnitude
- if dist < nearestDistance then
- nearestDistance = dist
- nearestPlayer = player
- end
- end
- end
- if nearestPlayer then
- local playerPos = nearestPlayer:getEntity():getPosition()
- local direction = (playerPos - center)
- if direction.Magnitude > 0 then
- direction = Vector3.new(direction.X, 0, direction.Z).Unit
- else
- direction = Vector3.new(0, 0, 1)
- end
- local playerAngle = math.atan2(direction.Z, direction.X)
- local leftAngle = playerAngle + angleOffset
- local rightAngle = playerAngle - angleOffset
- for i, part in ipairs(leftLineParts) do
- local distance = step * i
- local newPos = center + Vector3.new(math.cos(leftAngle) * distance, 0, math.sin(leftAngle) * distance)
- part:setPosition(newPos)
- part:setCFrame(CFrame.lookAt(newPos, woolBlock.position + Vector3.new(0, 1.5, 0)) * rotationOffset)
- end
- for i, part in ipairs(rightLineParts) do
- local distance = step * i
- local newPos = center + Vector3.new(math.cos(rightAngle) * distance, 0, math.sin(rightAngle) * distance)
- part:setPosition(newPos)
- part:setCFrame(CFrame.lookAt(newPos, woolBlock.position + Vector3.new(0, 1.5, 0)) * rotationOffset)
- end
- for i, part in ipairs(topParts) do
- local t = i / (newCapPartsCount + 1)
- local capAngle = (leftAngle * (1 - t)) + (rightAngle * t)
- local capPos = center + Vector3.new(math.cos(capAngle) * (radius + 0.3), 0, math.sin(capAngle) * (radius + 0.3))
- part:setPosition(capPos)
- part:setCFrame(CFrame.lookAt(capPos, woolBlock.position + Vector3.new(0, 1.5, 0)) * rotationOffset)
- end
- end
- task.wait(0)
- end
- end)
- end
- end
Advertisement
Comments
-
- Showcase : https://discord.com/channels/1132704840313749615/1341227620926492752/1341227620926492752
- Note : place down a wool_red block on ground for Script work this a script for coders can use so it only has radius and find nearby entity's function
Add Comment
Please, Sign In to add comment
Advertisement