0 views0 copies0 likes
Safe Zone Attribute for Server Logic
Universal script
Copy it, then test it in your own Studio place.
Script code
13 lines ยท 0.6 KBlocal Players = game:GetService("Players")local zone = workspace:WaitForChild("SafeZone")while zone.Parent do local half = zone.Size / 2 for _, player in Players:GetPlayers() do local root = player.Character and player.Character:FindFirstChild("HumanoidRootPart") local point = root and zone.CFrame:PointToObjectSpace(root.Position) local inside = point ~= nil and math.abs(point.X) <= half.X and math.abs(point.Y) <= half.Y and math.abs(point.Z) <= half.Z if player:GetAttribute("InSafeZone") ~= inside then player:SetAttribute("InSafeZone", inside) end end task.wait(0.15)endAbout this script
Add an anchored box named SafeZone and set CanCollide off. The server checks player root positions against the box in the part's local coordinates, so rotating the box still works. It puts a boolean InSafeZone attribute on each player for your combat or interaction rules to read. Test the corners and the vertical boundary before connecting it to damage logic.
Log in to leave a comment.
No comments yet
Be the first to share your thoughts!
Comments
Share what works, ask questions, or report an issue.