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

How to Detect If a Player Walked Away from a Brick?

Asked by 4 years ago

So I working on creating NPC's for my game using custom GUI's (not the default roblox chat boxes), but I don't know how to detect if a player walks too far away from the NPC while talking to them? Is there a way to do this easily?

0
Magnitude is good like IceAndNull said, and you would just use if statements to tween the guis away if they walk too far, or you can use Region3 to see if the NPC is near the character. ScrubSadmir 200 — 4y

1 answer

Log in to vote
2
Answered by 4 years ago

I think so, using .magnitude. Basically you would subtract the NPCs position from the players position, giving you a vector3. Then use .magnitude on the vector3 and it will give you the absolute distance from the NPC like this

local Distance = (Character.HumanoidRootPart.Position-NPC.HumanoidRootPart.Position).magnitude

Sorry if it doesn't work, you can comment the error if you want

Ad

Answer this question