Issue with MoveTo() and Humanoid.MoveDirection

Hello.

I’m trying to see if the player moves at all during an event. If the player moves, it works just fine, because MoveDirection.magnitude > 0.

The problem is, if I use MoveTo() on the player’s humanoid, this function doesn’t get triggered. I’m assuming because of it only sees user input as a movement.

What are some good ways to tell if the player is moved all? Regardless of user input?

Thanks!

1 Like

You can use this property to detect if a player is moving and in what direction. Humanoid | Documentation - Roblox Creator Hub

You can also use the Humanoid.Running event, which if they are moving, their speed will be greater than zero. Humanoid | Documentation - Roblox Creator Hub

I hope this helps!

1 Like

MoveDirection is not updated when :MoveTo is used, so it can’t be used in this case.
The humanoid.Running event runs if the player moves at all, even if another player pushed them or something. If we only want it to react when the player themselves tries to move, humanoid.Running doesn’t work.

How can one get MoveDirection to update then? Is there another way to move a humanoid other than :MoveTo?

I don’t know how efficient it would be but you could possibly check for currently playing animations…

Humanoid.Animator:GetPlayingAnimationTracks()
    if animation.Name == "idle" then --etc
    elseif animation.Name == "WalkAnim" then --etc

Very late to this, but you can use MoveDirection.magnitude by replicating MoveTo() using Move().

Set the angle of Humanoid:Move() to a CFrame.lookAt value. Then just repeat wait until the magnitude hits the part.

local Humanoid = script.Parent:WaitForChild("Humanoid")
local Torso = script.Parent:WaitForChild("Torso") -- If you're using R15, set Torso to LowerTorso.
local Destination = workspace:WaitForChild("Part")

local a = CFrame.lookAt(Torso.Position, Destination.Position) 
Humanoid:Move(a.LookVector, false) 

repeat 
	local m = (Torso.Position - Vector3.new(Destination.Position.X, Torso.Position.Y, Destination.Position.Z)).Magnitude 
	-- I only did this so the Y value of the Destination is the same as the torso. Feel free to replace the entire Vector3 with Destination.Position
	print(string.format('Magnitude: %i', m)) -- This is optional, but I like to know details. :)
	task.wait() 
until m < 0.2 -- From what I know, the Magnitude of a position is somehow different based on angles. 0.2 is the only value that I know can support all of these angles.

Humanoid:Move(Vector3.new(0,0,0), false) -- Stops the humanoid from moving
1 Like