Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local rs = game:GetService("RunService")
- local ps = game:GetService("Players")
- local function isInsideBrick(position, brick)
- local v3 = brick.CFrame:PointToObjectSpace(position)
- return (math.abs(v3.X) <= brick.Size.X / 2)
- and (math.abs(v3.Y) <= brick.Size.Y / 2)
- and (math.abs(v3.Z) <= brick.Size.Z / 2)
- end
- local function getPlayersInsideZone(zone)
- local list = {}
- for _, player in ipairs(ps:GetPlayers()) do
- if (player.Character) then
- local torso = player.Character:FindFirstChild("HumanoidRootPart")
- if (torso and isInsideBrick(torso.Position, zone)) then
- table.insert(list, player)
- end
- end
- end
- return list
- end
Advertisement
Add Comment
Please, Sign In to add comment