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

Animation stops when walking?

Asked by 3 years ago

I would like to change the animation priority to play over walking and jumping. I currently have it so that when E is pressed the player does a frontflip, but the moment they start walking it stops.

I had read this: https://developer.roblox.com/en-us/api-reference/enum/AnimationPriority

I tried doing this. However it returns an error.

local flip = Instance.new("Animation")
flip.AnimationPriority = 2
0
Enum.AnimationPriority.Action ? Pupppy44 671 — 3y
0
I think that is what I need. How would I incorporate that into the script? If you answer below, I can accept your answer :) Amanda314159 291 — 3y
0
I tried "Enum.AnimationPriority.Action = flip" , but this gives the error "Action cannot be assigned to " Amanda314159 291 — 3y

1 answer

Log in to vote
0
Answered by
Roger111 347 Moderation Voter
3 years ago
Edited 3 years ago

Answer: Just add an event to the humanoid that detects when the player jumps, and play the animation. Rather than doing the front-flip when they press E.

Note: I did this in a LocalScript in StarterCharacterScripts

Code:

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

local isJumping = false

humanoid.StateChanged:Connect(function(oldState, newState)
    if newState == Enum.HumanoidStateType.Jumping then
        if not isJumping then
            isJumping = true
            print("Started jump..!")

            --Play animation here

        end
    elseif newState == Enum.HumanoidStateType.Landed then
        if isJumping then
            isJumping = false
            print("Ended jump..!")

--[[ You will stop the animation here if you only want it to play during the jump, if you want it to finish playing out then don't. ]]

        end
    end
end)
Ad

Answer this question