Advertisement
Cat_in_the_hat

Radius update better test

Dec 2nd, 2024
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. local playerFirstBlockPosition = {}
  2. local playerCircleParts = {}
  3.  
  4. local function createCircleParts(centerPosition, circleRadius)
  5. local partCount = 8 + (circleRadius * 2)
  6. local partSize = Vector3.new(1, 0.2, 0.3)
  7. local spaceGap = 0.5
  8. local parts = {}
  9.  
  10. for i = 1, partCount do
  11. local angle = (i / partCount) * math.pi * 2
  12. local offsetX = math.cos(angle) * (circleRadius + partSize.X / 2 + spaceGap)
  13. local offsetZ = math.sin(angle) * (circleRadius + partSize.X / 2 + spaceGap)
  14. local partPosition = centerPosition + Vector3.new(offsetX, 0, offsetZ)
  15.  
  16. local part = PartService.createPart(ItemType.WOOL_WHITE, partPosition)
  17. part:setSize(partSize)
  18. part:setAnchored(true)
  19. part:setCollidable(false)
  20.  
  21. local lookAtCFrame = CFrame.new(partPosition, centerPosition)
  22. part:setCFrame(lookAtCFrame)
  23.  
  24. table.insert(parts, part)
  25. end
  26.  
  27. return parts
  28. end
  29.  
  30. local function updateCirclePosition(parts, newCenterPosition, circleRadius)
  31. local partCount = #parts
  32. local partSize = Vector3.new(1, 0.2, 0.3)
  33. local spaceGap = 0.5
  34.  
  35. for i = 1, partCount do
  36. local angle = (i / partCount) * math.pi * 2
  37. local offsetX = math.cos(angle) * (circleRadius + partSize.X / 2 + spaceGap)
  38. local offsetZ = math.sin(angle) * (circleRadius + partSize.X / 2 + spaceGap)
  39. local partPosition = newCenterPosition + Vector3.new(offsetX, 0, offsetZ)
  40.  
  41. parts[i]:setPosition(partPosition)
  42.  
  43. local lookAtCFrame = CFrame.new(partPosition, newCenterPosition)
  44. parts[i]:setCFrame(lookAtCFrame)
  45. end
  46. end
  47.  
  48. local function updateCircleAroundFirstBlock(player)
  49. local entity = player:getEntity()
  50. if not entity then
  51. return
  52. end
  53.  
  54. local position = entity:getPosition()
  55. local yPosition = position.Y
  56. local centerPosition = position + Vector3.new(0, -10, 0)
  57.  
  58. local reachedBottom = false
  59.  
  60. while true do
  61. yPosition = yPosition - 1
  62. local checkPosition = Vector3.new(position.X, yPosition, position.Z)
  63.  
  64. local blockBeneath = BlockService.getBlockAt(checkPosition)
  65.  
  66. if blockBeneath then
  67. local previousBlockPosition = playerFirstBlockPosition[player.userId]
  68.  
  69. if previousBlockPosition ~= checkPosition then
  70. centerPosition = checkPosition + Vector3.new(0, 1.6, 0)
  71. local circleRadius = 13
  72.  
  73. if not playerCircleParts[player.userId] then
  74. playerCircleParts[player.userId] = createCircleParts(centerPosition, circleRadius)
  75. else
  76. updateCirclePosition(playerCircleParts[player.userId], centerPosition, circleRadius)
  77. end
  78.  
  79. playerFirstBlockPosition[player.userId] = checkPosition
  80. end
  81. break
  82. end
  83.  
  84. if yPosition <= position.Y - 500 then
  85. reachedBottom = true
  86. break
  87. end
  88. end
  89.  
  90. if reachedBottom then
  91. centerPosition = position + Vector3.new(0, -10, 0)
  92. if playerCircleParts[player.userId] then
  93. updateCirclePosition(playerCircleParts[player.userId], centerPosition, 13)
  94. end
  95. end
  96. end
  97.  
  98. while true do
  99. for _, player in pairs(PlayerService.getPlayers()) do
  100. updateCircleAroundFirstBlock(player)
  101. end
  102. task.wait(0.1)
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement