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

Walking a certian distance towards player target?

script.Parent.Humanoid:MoveTo(Target.Value.Character.Torso.Position , Target.Value.Character.Torso)

How can I make it so it only goes say, half way towards the target?

1 answer

✓ Accepted answer

The trick is to only make it move towards the midsection. For this I'll use lerp so that you can reasonably change the fraction of the distance it covers.

script.Parent.Humanoid:MoveTo(Target.Value.Character.Torso.Position:lerp(script.Parent.Position, 0.5) , Target.Value.Character.Torso)

I'm not sure whether you want the second argument in this case, but I've kept it because I don't have the context of your application.

2 comments

0

^ when I do that the npc moves with my turns like I turn right and he turns right, is there anyway for him to just follow me at a distance

0

Yeah that's why I said you probably don't want the second argument. The issue is of course that now you're talking about having a distance restraint which is a totally different ordeal.

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