I’m trying to make a sprint script that stops the animation when you jump and replay it when you land but when I try to use humanoidstatetype.landed it does not trigger
the code
Humanoid.StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.Jumping or new == Enum.HumanoidStateType.Freefall or new == Enum.HumanoidStateType.Climbing then
PlayAnim:Stop()
WalkingTween:Play() SprintingTween:Pause()
if new == Enum.HumanoidStateType.Landed or old == Enum.HumanoidStateType.Freefall or old == Enum.HumanoidStateType.Landed then
if Sprinting then
PlayAnim:Play()
WalkingTween:Pause() SprintingTween:Play()
end
end
end
end)
Humanoid.StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.Jumping or new == Enum.HumanoidStateType.Freefall or new == Enum.HumanoidStateType.Climbing then
PlayAnim:Stop()
WalkingTween:Play() SprintingTween:Pause()
elseif new == Enum.HumanoidStateType.Landed or old == Enum.HumanoidStateType.Freefall then
if Sprinting then
PlayAnim:Play()
WalkingTween:Pause() SprintingTween:Play()
end
end
end)
@Qmenator What your issue was is that you check the landed inside of the jump. So when the state is changed, it checks if new == Jumping, it does so it continues on. Inside the if block, you then check if new == Landed, however since the first if statement passed true, new is equal to Jumping. You want to do what this guy posted, which is to split up the if statement into an if elseif block. If the player landed, the state cant be Jumping, so the first if statement will be false, and the second will be true.