#LoadAnimation can't find Animation object

1 messages · Page 1 of 1 (latest)

wary burrow
#

the animation objects (1,2,3,4) have animation id's

finite oakBOT
#

studio** You are now Level 1! **studio

wary burrow
#

the error btw

solar badge
#

give m1animationcycle:getchildren() a different variable name from Animation, maybe something like Animations or AnimationList, make sure M1Combo.Value is a number from 1 to 4, and you could probably write the animation variable as

Animation = AnimationListVariable:FindFirstChild(tostring(M1Combo.Value))```
#

what is M1Combo.Value?

#

try printing it's value

zinc eagle
#

naming collision?

#

;compile lua lua local t={x=1} local t=t.x print(t)

serene epochBOT
#
Program Output
1

zinc eagle
#

that's just jank bruh

#

anyway maybe the value is 0 or something, either way the error is saying animation is probably nil

wary burrow
wary burrow
#

Alright I worked on it myself and it finally sort of works

#

It just

#

it only does it once though

#

Alright I fixed it myself

#

thanks so much everyone for the help

#
local Players = game:GetService("Players")

local Events = ReplicatedStorage.Events
local AttackHitboxes = require(script.Parent.AttackHitboxes)
local SaberM1Debounces = {}

Events.SaberM1.OnServerEvent:Connect(function(Player)
    local Character = Player.Character
    if not Character then return end

    local Humanoid = Character:FindFirstChild("Humanoid")
    if not Humanoid or Humanoid.Health <= 0 then return end

    if SaberM1Debounces[Player] then return end
    SaberM1Debounces[Player] = true

    local M1Combo = Player.Values.M1Combo
    local Animations = script.M1AnimationCycle:GetChildren()

    local comboNumber = tonumber(M1Combo.Value) or 1

    
    if comboNumber > #Animations then
        M1Combo.Value = 1
    else
        M1Combo.Value = comboNumber + 1
    end

    local Animation = Animations[comboNumber]  

    if Animation then
        local LoadedM1Animation = Humanoid.Animator:LoadAnimation(Animation)
        LoadedM1Animation:Play()
        task.wait(LoadedM1Animation.Length)
    else
        warn("Animation not found for combo:", comboNumber)
    end

    SaberM1Debounces[Player] = nil  
end)```