Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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!

0
try using "(part1.Position - Part2.Position).magnitude < number" Tizzel40 243 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

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.

Ad
Log in to vote
0
Answered by 5 years ago

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.

Answer this question