Custom Animation - Help Needed

  1. What do you want to achieve?
    i want to have a jump animation and it go back to the walking animation

  2. What is the issue?

  3. What solutions have you tried so far?
    i am still learning roblox studios code so the best i could think was to add “then walkAnim:Play()” but that just made the character walk as soon as spawning in

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local walkAnim = animator:LoadAnimation(character:WaitForChild('Walking'))
local jumpAnim = animator:LoadAnimation(character:WaitForChild('Jumping'))

humanoid.Running:Connect(function(speed)
	if speed > .1 then 
		if not walkAnim.IsPlaying then
			walkAnim:Play()
		end
		walkAnim:AdjustSpeed(speed/16)
	else
		if walkAnim.IsPlaying then 
			walkAnim:Stop()
		end
	end
end)

humanoid.StateChanged:Connect(function(old,new)
	if new == Enum.HumanoidStateType.Jumping then
		jumpAnim:Play()
	end
end)```

when the humanoid state type changes to not jumping you should run jumpAnim:Stop()

so how would that look altogether ?

replace this with

humanoid.StateChanged:Connect(function(old,new)
	if new == Enum.HumanoidStateType.Jumping then
		jumpAnim:Play()
    else
        jumpAnim:Stop()
	end
end)
1 Like

alright i did that but now it doesn’t play long enough? it just BARELY starts the animation
edit : at least it goes back to idle / walking when i walk though

try replacing else with

elseif new == Enum.HumanoidStateType.Landed then

you can also try all the other state types listed here
https://create.roblox.com/docs/reference/engine/enums/HumanoidStateType

1 Like

that worked thanks a lot for helping :sweat_smile:
edit : and yea i will look into roblox code more

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