How to stop Humanoid:MoveTo()?

What? I already have this figure out, I just needed help with stopping the MoveTo

1 Like

Use this :

humanoid:ChangeState(Enum.HumanoidStateType.None)

In script :

module.playerFound = function(botCharacter) -- this runs when the player is too close to the bot
	local humanoid = botCharacter:FindFirstChildOfClass("Humanoid")
	local humanoidRootPart = botCharacter:FindFirstChild("HumanoidRootPart")
	if humanoid and humanoidRootPart then
		print("Move")
		humanoid:MoveTo(humanoidRootPart.Position) -- this is it moving to its self
		humanoid.WalkToPart = humanoidRootPart
		humanoid.WalkToPoint = humanoidRootPart.Position
		humanoid.MoveToFinished:Wait()
		print("Moved") -- both of these print right after each other
        humanoid:ChangeState(Enum.HumanoidStateType.None)
	end
	return
end
11 Likes

Why is it that when I use this method, well the collisions of my npc’s legs and arms are disabled and therefore cross the ground?

Yet there are collisions.

1 Like

Please do not bump old topics (I know i bumped too)

Anyways, the reason this happens is because the arms and legs does not have a collision in the first place. The humanoid only increases the “height” of the character making the legs look like they have collision.
When you platform stand, you “disable” the humanoid and the height increase is disabled too, making the legs clip through the ground

2 Likes

Try Using This,

humanoid:MoveTo(humanoidRootPart.Position - humanoidRootPart.Position.CFrame.LookVector * X)

X = The distance you want them to stop, I used this earlier for a dummy to move towards the player so this should work. I hope this helps! :slight_smile: :+1:

3 Likes

I know I’m necroposting, but I’ve seen this question asked so many times, and so far, I haven’t found any good answer to it.
When this happens to me, i use,

humanoid:Move(Vector3.new(0,0,0))

…and it works fine. Have you tried that?

I dont think a bot can move to its self because the bot has one position and the bot cant follow its self

No, :Move makes the npc move vector3 forward, where vector3 is the parameter passed. You’re thinking :MoveTo, which makes the bot move to the position vector 3. it’s like part.Position = vector3 versus part.Position += vector3.

repeat task.wait() until (bot.Position - plr.Character.Humanoid.Position).Magnitude >= 2
bot.Humanoid:MoveTo(bot.HumanoidRootPart.Position)
1 Like

Sorry for the necro but I was trying to solve this issue too a while ago, I know how to stop it without causing any other side effects.


You can set the WalkToPoint to the characters position, which I’ve tested and does not make the npc spin around endlessly. You would have to change the script for your needs but this is what I made in the demo video (You should change primary part to HumanoidRootPart, I just now realized that R15’s primary part is Head):


game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if msg == "go" then
			script.Parent.Humanoid:MoveTo(
				Vector3.new(
					math.random(-200,200),
					script.Parent.PrimaryPart.Position.Y,
					math.random(-200,200)
				)
			)
		elseif msg == "stop" then
			script.Parent.Humanoid.WalkToPoint = script.Parent.PrimaryPart.Position
		end
		
	end)
end)
1 Like

I think it might be spinning because of the gun