Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to stop animation while in certain humanoidstatetype?

Asked by 2 years ago

I want to stop this sprinting animation while I am jumping or falling but it does not seem to work. Here is code where I want it to check for the state and stop the script...

while true do
    wait()
    if Enum.HumanoidStateType.Jumping or Enum.HumanoidStateType.Freefall then
    sprintAnim:Stop()
    end
end

Not sure if this is a mistake or another piece of code in my local script is preventing it on working. Please help and explain I am new to scripting and still learning. Thanks :) Code for sprinting

-- Sprint Key Pressed
userInputService.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift then
        if currentStamina >= staminaCost and character.Humanoid.MoveDirection.Magnitude > 0 then
            character.Humanoid.WalkSpeed = sprintSpeed
            sprintAnim:Play()
        end
    end
end)

2 answers

Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
2 years ago

Your sprinting is good but you're not checking the players humanoid state you're only checking humanoidstatetype which errors you!

while wait() do
    if character.Humanoid:GetState() == Enum.HumanoidStateType.Jumping or character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
        sprintAnim:Stop()
    end
end
0
Thank you, this worked! Zsows77 2 — 2y
0
Np! MattVSNNL 620 — 2y
Ad
Log in to vote
0
Answered by
enes223 327 Moderation Voter
2 years ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Answer this question