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

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

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?

1 comment

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.

1 answer

✓ Accepted answer

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

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