Playing animation on jump

Hello, the lost people,

I am trying to make a simple animate script. But I need help with making it play animation on jump. Hope you guys can help :smiley:

Code
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

local animations = {
	Idle = humanoid:LoadAnimation(humanoid:WaitForChild("Idle")),
	Walk = humanoid:LoadAnimation(humanoid:WaitForChild("Walk")),
	Jump = humanoid:LoadAnimation(humanoid:WaitForChild("Jump"))
}

humanoid.Running:Connect(function(speed)
	if speed > 0.2 then
		animations["Walk"]:Play()
		animations["Idle"]:Stop()
	else
		animations["Walk"]:Stop()
		animations["Idle"]:Play()
	end
end)

humanoid.Jumping:Connect(function(active)
	-- I want to make the animation play from here
end)

animations["Idle"]:Play()

Canโ€™t you just play the Jump animation like you did on your Running function? You just need to add a check if the Player has started/finished jumping

humanoid.Jumping:Connect(function(active) --active would be known as a Bool for this instance
	if active then
		animations["Jump"]:Play()
		animations["Idle"]:Stop()
    else --If the Humanoid stopped jumping, we set back to idle
		animations["Jump"]:Stop()
		animations["Idle"]:Play()
    end
end)
10 Likes