Way to detect if Player is moving without using Humanoid.Running?

Hi, I am making a flying script that uses the Humanoid’s Move Direction as well as the CurrentCamera CFrame to move the player.

The script disables the Running and Swimming HumanoidStateType before the player starts flying.
This script works, but when you look up and down even when the player isn’t moving their character, the character moves up and down. I do not want the Player’s Character to move if they are not moving with WASD or a touch pad. I do not want to use Keycodes because I want this to work for mobile as well.

while Flying do
     wait()
     BodyVelocity.Velocity = Hum.MoveDirection*FlySpeed +(game.Workspace.CurrentCamera.CFrame.lookVector*Vector3.new(0,FlySpeed,0))
end

How can I detect if the player is moving so I can activate the up and down motion of the player’s character depending on where they are looking?

Nevermind! When the player is not moving, the MoveDirection property goes back to (0,0,0)
This fixed it:

while Flying do
		wait()
		if Hum.MoveDirection ~= Vector3.new(0,0,0) then
			Bv.Velocity = Hum.MoveDirection*FlySpeed + (game.Workspace.CurrentCamera.CFrame.lookVector*Vector3.new(0,FlySpeed,0))
		else
			Bv.Velocity = Hum.MoveDirection
		end
end
2 Likes