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

Script errors and outputs an "animation failed to load in..." error?

Asked by
Duksten 20
6 years ago
Edited 6 years ago

I have this script that allows the player to press E and punch which plays an animation and also does damage. It works fine in studio, however when played online it gives me an error that says:

Animation "..." failed to load in "..." :Animation Failed to load.

I have a local script and a regular script that uses remote events to communicate with each other.

Here is the local script:

local UIS = game:GetService("UserInputService")

local canPunch = true

local function onKeyPressed(input)
    if input.KeyCode == Enum.KeyCode.E and canPunch then
        script.Parent:WaitForChild("PunchEvent"):FireServer()
        canPunch = false
        local punchRate = 1
        wait(punchRate)
        canPunch = true
    end

end

UIS.InputBegan:Connect(onKeyPressed)

And here is the server script:

local punchEvent = script:WaitForChild("PunchEvent")
local punchAnimation = script:WaitForChild("Punch")
local canHurt = true
local isSwinging = false

punchEvent.OnServerEvent:Connect(function(player)

    local humanoid = script.Parent:WaitForChild("Humanoid")
    local animation = humanoid:LoadAnimation(punchAnimation)

    animation:Play(0.4, 1, 1)
    wait(0.25)
    animation:AdjustSpeed(0)
    wait(0.2)
    animation:AdjustSpeed(2)
    isSwinging = true
    canHurt = true
    wait(0.3)
    isSwinging = false

    local rightHand = script.Parent:WaitForChild("RightHand")

    rightHand.Touched:Connect(function(hit)

        if not isSwinging then return end
        if not canHurt then return end

        canHurt = false     

        if hit and hit.Parent:FindFirstChild("Humanoid") then
            local human = hit.Parent:FindFirstChild("Humanoid")
            human:TakeDamage(10)
        end

        wait(0.3)
        canHurt = true


    end)


end)

1 answer

Log in to vote
0
Answered by 6 years ago

This error means the animation could not be used. One of two scenarios can cause this error:

A. The animation must be owned by the game/group creator or ROBLOX.

B. The animation has been deleted by ROBLOX.

Ad

Answer this question