Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is it possible if a Character gets away from an object a certain distance, a then statement happens?

basically, I've got this script.

while true do for _,P in pairs(game.Players:GetPlayers()) do if P:DistanceFromCharacter(game.Workspacet.Part.Position) < 2 then P.Character.HumanoidRootPart.Position = game.Workspace.Part.Position end end wait() end

It doesn't work, can someone help me? Thanks in advance!

1 comment

0

try using "(part1.Position - Part2.Position).magnitude < number"

2 answers

✓ Accepted answer

You can study the player's math.magnitude value to get the distance in a while true or repeat script, then if the character or whatnot moves so and so far away you can fire your next move.

I don't know if this is what you want, but you said if a player gets a certain distance away from a position. You might need to change the < sign to a > sign, for greater than instead of less than.

This discussion is preserved as it was. New answers, comments, and votes are closed.