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

Error "attempt to index nil with AnimationId"?

Asked by 2 years ago

**ServerScriptService.Combat Server.Combat_Handler:19: attempt to index nil with 'AnimationId' ** This is just the animations part of a combat system from a video i was practicing with, just wondering what was wrong with it. Thanks!

local Animations = script:WaitForChild("Animations")

local KeyProvider = game:GetService("KeyframeSequenceProvider")

local Combat_Handler = {
    MeleeAnims =
    {
        ["L"] = Animations.Melee1,
        ["LL"] = Animations.Melee2,
        ["LLL"] = Animations.Melee3,
        ["LLLL"] = Animations.Melee4
    }
}


function Combat_Handler:getAnimation(Humanoid, sequence)
    local length = 0

    local keysequence = KeyProvider:GetKeyframeSequenceAsync(Combat_Handler.MeleeAnims[sequence].AnimationId)
    local keyframes = keysequence:GetKeyframes()

    for i=1, #keyframes do
        local Time = keyframes[i].Time
        if Time > length then
            length = Time
        end
    end

    return Humanoid.Animator:LoadAnimation(Combat_Handler.MeleeAnims[sequence]), length
end
return Combat_Handler

Answer this question