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

Why won't the animation play when the player presses F?

Asked by 4 years ago

I don't know too much about animations sooo idk what I did wrong

game.Players.PlayerAdded:Connect(function(plr)
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.F then
        local animation = Instance.new("Animation")
animation.AnimationId = "3560009028"
local animTrack = nil
local canPlay = true

function playShockAnim()
    if canPlay then
        local player = plr
        canPlay = false
        animTrack = player.Humanoid:LoadAnimation(animation)
        canPlay = true
        animTrack:Play()
    end
end

playShockAnim(plr)
    end
end)
end)
0
idk man Or1g1nal_Player 22 — 4y
0
What's the error message? iiDkOffical 109 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Ok so your formatting is a little confusing but when a rearranged it, it looks like this

game.Players.PlayerAdded:Connect(function(plr)
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.F then
        local animation = Instance.new("Animation")
        animation.AnimationId = "3560009028"
        local animTrack = nil
        local canPlay = true

        function playShockAnim()
            if canPlay then
                local player = plr
                canPlay = false
                animTrack = player.Humanoid:LoadAnimation(animation)
                canPlay = true
                animTrack:Play()
            end
        end
        playShockAnim(plr)
    end
end)
end) -- extra end)?

I don't understand why you have a function defined when the player presses f instead of just doing what the function does. The real problem is that the animation ID should be "rbxassetid://3560009028" instead of just "3560009028", which is probably why your animation isn't playing, also you should make your animation priority higher so it doesn't get interupted by movement animations.

Ad

Answer this question