Is there a way to detect a cancel Humanoid.MoveTo()

I want to know if there is a way to detect if a player has moved their character while moveto is active.

You could always call the Humanoid:MoveTo() function on the player’s current position, effectively stopping them as they’ve already reached their current position.

You might be able to anchor the HumanoidRootPart of the player as well.

I want the player to move to a part, but I also want to give them the freedom of cancelling the movement, I don’t want to force stop them sorry if I’m unclear.

Yeah so I think moving the Humanoid to the player’s current position would still work in this case. The humanoid:MoveTo() function runs until the humanoid has reached the desired position, meaning that if you call this function and input the player’s current position, it in theory shouldn’t run, or run for a very short amount of time, as the player is already there. For example:
humanoid:MoveTo(HumanoidRootPart.Position)

I don’t understand why I would need this, if i want a player to move to a parts position i dont get why keeping the player in place would do anything.

sorry I realise my title said is there a way to cancel moveto i meant detect a cancel

I thought you said you wanted a system that would:

  1. Move to player to a certain part’s position
  2. If the player wanted to cancel that movement, it would cancel the MoveTo() function and allow the player control of their character again.

Is this not what you want?

Ah ok. I don’t think there is any way to detect if Humanoid:MoveTo() has been canceled. There is a Humanoid MoveToFinished() event, but this only fires once the MoveTo() function has ended.

Maybe you can have a variable that stores a true or false, and then when the MoveTo() function is called, set that variable to true and start a while loop that runs only when the Humanoid.MoveDirection.Magnitude is > 0. If the while loop ends, that means the Humanoid has stopped moving, meaning either:

  1. The character reached their desired position
  2. The player canceled the MoveTo() function

Sorry for the misunderstanding, I want to move the player to a certain part’s position, then if the player is to move i want a way to check if they player has broke the moveto()

but then what if i want to detect a mobile user, is there not just a way to detect the moveto() has cancelled?

If the option above doesn’t work for you then you can try determining if the player is still moving in the direction of the desired MoveTo position. Every 0.5 seconds or so, check the magnitude difference of both points and if the result is getting shorter it means they’re getting closer to the point. If the magnitude result stays the same or gets bigger it means they’ve cancelled the MoveTo function because they’re no longer moving or they started moving in a different direction.

Another way you could do this is if the player doesn’t get close to the point within the threshold of time that it should take them. I don’t know the specifics but it depends on the Humanoid.WalkSpeed, current position of the HumanoidRootPart and the target position. You can create some math formula to determine how long it should take them to reach their target position and then just wait that long, if they aren’t close to it then they must’ve cancelled it.


I tried to see if monitoring Humanoid.WalkToPoint would work but it unfortunately doesn’t and I think it’s because of a bug. If you call :MoveTo on a humanoid it sets the WalkToPoint to that position, however if you cancel it doesn’t ever go back to 0,0,0 it just stays to the desired position even though you’ve cancelled it.

I can’t report bugs but I don’t think that’s intended behavior.

1 Like

alright thanks ill just use this, i was just wondering if there was an inbuilt function with moveto to detect if it was cancel

you can do this so when the player tries to walk in a new direction so you know the moveto was cancelled

local humanoid = game.Players.LocalPlayer.Character.Humanoid
local isMovingTo = false

humanoid.MoveToFinished:Connect(function(reached)
	isMovingTo = false
end)

humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	if isMovingTo == false then return end
	print("MoveTo Cancelled")
end)

local MovePlayer = function(location)
	isMovingTo = true
	humanoid:MoveTo(location)
end

MovePlayer(Vector3.new(1000, 0, 0))
2 Likes