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

Im having trouble getting an npc to walk to another npc but still keep a distance away?

Asked by 4 years ago
Edited 4 years ago

I have an npc (npc1) that is walking to another npc (npc2). I want the walking npc to walk to the other but stop when it is 5 or 10 studs away. the function I have wont do this and instead the npc tries to walk to the same exact position as the other.

here is the function:

function gototarget(p)
   script.Parent.GoTo.Value = p.Position,script.Parent.Parent.HumanoidRootPart.Position 
end

p is a part inside npc2, and the humanoidrootpart is inside npc1. but npc1 wont stop 5 or 10 studs away. it instead goes exactly were npc2 is. what should I do to fix this?

Answer this question