How would I know if the player is moving up or down?

Hello, how would I know if a charcater is moving up or down? I tried using MoveDirection but the y is always 0. I also tried using humanoid state types but there seems to be no state of moving up. Please help!

I don’t think Humanoid.MoveDirection will ever have the Y axis changed unless it’s climbing or something. I suggest using GetPropertyChangedSignal on the position Property of the HumanoidRootPart and checking if the Y axis changes, the higher, or the lower. Or AssemblyLinearVelocity.

Thanks for the response! I’ll try using AssemblyLinearVelocity.

You can’t use GetPropertyChangedSignal on properties handled by the physics engine.

local Game = game
local RunService = Game:GetService("RunService")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local PivotY = Character:GetPivot().Y

local function OnRenderStep()
	local Y = Character:GetPivot().Y
	if Y  > PivotY then
		print("Moving up!")
	elseif Y < PivotY then
		print("Moving down!")
	end
	PivotY = Y
end

RunService.RenderStepped:Connect(OnRenderStep)
2 Likes