Tool Animation Play on Jump

I am trying to do a jump script that when my character jumps, It will play a different animation if I am holding the specific tool. But I have been struggling to do that as most stuff did not work

local function checkAirborne()
	if equipped then

if humanoid.FloorMaterial ~= Enum.Material.Air then
			JumpAnim:Stop()
		end
	end
end

humanoid.Jumping:connect(function(jump)
	if equipped then
		JumpAnim:Play()
	end
end)



while true do
	checkAirborne()
	wait(0.1) 
end

The script can detect if I am not in the air (On the ground) but It cannot detect when it jumps, can someone help?

1 Like

a better way to do this is with signals so that you don’t have a loop running when it doesn’t need to

humanoid.StateChanged:Connect(function(old, new)
	if new == Enum.HumanoidStateType.Jumping then
		print("Jumped")
	elseif new == Enum.HumanoidStateType.Landed then
		print("Landed")
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.