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

exceeding maximum animation track limit?

Asked by 4 years ago
local forward = script.Forward
local left = script.Left
local right = script.Right
local run = script.Run
local back = script.Back
local forwardvel = script.Parent.Parent.Parent.Forward
local angler = script.Parent.Parent.Parent.Turn



while true do
    wait()
    if forward.Value == true then
        run.Value = false
        back.Value = false
        --play an animation------------------------------------------------
        local controller = script.Parent.Parent.Parent.Parent.AnimationController
        local chosenanim = script.Parent.Parent.Parent.Animations.Walk
        local loaded = controller:LoadAnimation(chosenanim)
        loaded:Play()
        -------------------------------------------------------------------
        forwardvel.Velocity = script.Parent.Parent.Parent.CFrame.LookVector * 15
    elseif forward.Value == false and back.Value == false then
        --stop an animation------------------------------------------------
        local controller = script.Parent.Parent.Parent.Parent.AnimationController
        local chosenanim = script.Parent.Parent.Parent.Animations.Walk
        local loaded = controller:LoadAnimation(chosenanim)
        loaded:Stop()
        -------------------------------------------------------------------
        forwardvel.Velocity = Vector3.new(0,0,0)
    end



    if left.Value == true then
        right.Value = false
        --play an animation------------------------------------------------
        local controller = script.Parent.Parent.Parent.Parent.AnimationController
        local chosenanim = script.Parent.Parent.Parent.Animations.Walk
        local loaded = controller:LoadAnimation(chosenanim)
        loaded:Play()
        -------------------------------------------------------------------
        angler.AngularVelocity = Vector3.new(0,2,0)
    elseif left.Value == false and right.Value == false then
        --stop an animation------------------------------------------------
        local controller = script.Parent.Parent.Parent.Parent.AnimationController
        local chosenanim = script.Parent.Parent.Parent.Animations.Walk
        local loaded = controller:LoadAnimation(chosenanim)
        loaded:Stop()
        -------------------------------------------------------------------
        angler.AngularVelocity = Vector3.new(0,0,0)
    end



    if right.Value == true then
        left.Value = false
        --play an animation------------------------------------------------
        local controller = script.Parent.Parent.Parent.Parent.AnimationController
        local chosenanim = script.Parent.Parent.Parent.Animations.Walk
        local loaded = controller:LoadAnimation(chosenanim)
        loaded:Play()
        -------------------------------------------------------------------
        angler.AngularVelocity = Vector3.new(0,-2,0)
    elseif right.Value == false and left.Value == false then
        --stop an animation------------------------------------------------
        local controller = script.Parent.Parent.Parent.Parent.AnimationController
        local chosenanim = script.Parent.Parent.Parent.Animations.Walk
        local loaded = controller:LoadAnimation(chosenanim)
        loaded:Stop()
        -------------------------------------------------------------------
        angler.AngularVelocity = Vector3.new(0,0,0)
    end



    if run.Value == true then
        forward.Value = false
        --play an animation------------------------------------------------
        local controller = script.Parent.Parent.Parent.Parent.AnimationController
        local chosenanim2 = script.Parent.Parent.Parent.Animations.Run
        local loaded2 = controller:LoadAnimation(chosenanim2)
        loaded2:Play()
        -------------------------------------------------------------------
        forwardvel.Velocity = script.Parent.Parent.Parent.CFrame.LookVector * 30
    end



    if back.Value == true then
        forward.Value = false
        run.Value = false
        --play an animation------------------------------------------------
        local controller = script.Parent.Parent.Parent.Parent.AnimationController
        local chosenanim = script.Parent.Parent.Parent.Animations.Walk
        local loaded = controller:LoadAnimation(chosenanim)
        loaded:Play()
        -------------------------------------------------------------------
        forwardvel.Velocity = script.Parent.Parent.Parent.CFrame.LookVector * -5
    elseif back.Value == false and forward.Value == false then
        --stop an animation------------------------------------------------
        local controller = script.Parent.Parent.Parent.Parent.AnimationController
        local chosenanim = script.Parent.Parent.Parent.Animations.Walk
        local loaded = controller:LoadAnimation(chosenanim)
        loaded:Stop()
        -------------------------------------------------------------------
        forwardvel.Velocity = Vector3.new(0,0,0)
    end



end

this script manages controls for an npc, if certain values are turned on or off this script performs actions. after adding animations for the npc to use I noticed an error:“AnimationTrack limit of 256 tracks for one animator exceeded. no new tracks will be played”. what is the cause and how can I fix it?

1 answer

Log in to vote
3
Answered by
Fifkee 2017 Community Moderator Moderation Voter
4 years ago
Edited 4 years ago

This is occuring because you are using a loop that loads animations every wait() interval (typically about 0.04-ish.) Because of this, you're constantly loading the same 5 animations into the Humanoid, which can stack up to over 256 within a few seconds.

You should load the animations at the start of the script (after preloading them to make sure you don't encounter any issues with playing the script), and then call :Play() on the AnimationTrack in the while loop.

Ad

Answer this question