Rhysical

soeting

Mar 30th, 2023
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. local rs = game:GetService("RunService")
  2. local ps = game:GetService("Players")
  3.  
  4. local function isInsideBrick(position, brick)
  5. local v3 = brick.CFrame:PointToObjectSpace(position)
  6. return (math.abs(v3.X) <= brick.Size.X / 2)
  7. and (math.abs(v3.Y) <= brick.Size.Y / 2)
  8. and (math.abs(v3.Z) <= brick.Size.Z / 2)
  9. end
  10.  
  11. local function getPlayersInsideZone(zone)
  12. local list = {}
  13. for _, player in ipairs(ps:GetPlayers()) do
  14. if (player.Character) then
  15. local torso = player.Character:FindFirstChild("HumanoidRootPart")
  16. if (torso and isInsideBrick(torso.Position, zone)) then
  17. table.insert(list, player)
  18. end
  19. end
  20. end
  21. return list
  22. end
Advertisement
Add Comment
Please, Sign In to add comment