I have,
dist = (Torso.Position - pos).magnitude if script.Parent.Postion < dist then script.Parent.Postion = dist end
but I can't seem to think of anyway to get it to follow at a distance of 3 and follow a set person. Ex: YellowTide.
The simplest architecture for this problem looks like this:
local distance = distanceToTarget; -- distance to target would probably be -- (myposition - targetposition).magnitude if distance < followDistance then -- I'm close enough STOP(); else -- I'm further than -- followDistance away GoTowards(target); end
Depending on the type of thing you want, how you would "stop" and "go towards" could be very different. For a Humanoid "stop" would just MoveTo
the position the humanoid is already at, and "go towards" would just MoveTo
the target.
Your "target" would be, in this case, the position of the player ('s torso) you are assigned to. This could be related by either ObjectValue references (or equivalent references through _G), StringValue, Name, or other player-name based ways to reference them (through game.Players[PlayerNameVariable]
), or by a parent relationship (the model following is a descendant of the player's character).