Humanoid:MoveTo() not working

Hello! I was wondering how I could make Humanoid:MoveTo() work! I can make it walker to a specific point, but when I try to add the second parameter which should theoretically make it follow the instance, it just doesn’t work. Does anybody know how to fix this?

entity.Humanoid:MoveTo(Vector3.new(),targetPlayer.HumanoidRootPart)

This is because I have been working an an enemy script, but I haven’t been able to make the enemy reach the player, only having it get close. I have tried almost everything online, like setting the HumanoidRootPart’s NetworkOwnership to nil, instead calculating the player’s position based on Humanoid:MoveDirection(). None of these helped get the enemy closer to the player, but I thought the second parameter in Humanoid:MoveTo()might help.

If anybody know why this isn’t working, please tell me. Thanks for reading this!

2 Likes

you never put a vector 3 pos. do this

entity.Humanoid:MoveTo(targetPlayer.HumanoidRootPart.Position)
2 Likes

I want too figure out how to use the second parameter, not just go to the location of the player

1 Like

You cannot make it work like that. You have to do it that way with :MoveTo().

how does the second parameter work though?

According to the documentation:

" If the part parameter is specified, the Humanoid will still attempt to walk to the point. However, if the part moves then the point the Humanoid is walking to will move to be at the same position relative to the part . If the part parameter is not specified, then the position the Humanoid is walking to will not change."

Either way, you’ll still have to define the first parameter. If that parameter moves (which I assume it will because you’re referencing a HumanoidRootPart, the above will happen as seen in the documentation. Try the following:

entity.Humanoid:MoveTo(targetPlayer.HumanoidRootPart.Position, targetPlayer.HumanoidRootPart)