I wrote a script on a gun holding animation and today i added another local script that plays an animation upon shooting. The holding animation worked before but now it gives me the error "LoadAnimation requires an Animation object " on line 14
carryTrack = animator:LoadAnimation(carryAnim)
I have no clue whats wrong as everything was working before. Is there a two animation limit? Any help is appreciated
the animator is build into humanoids so you could just do:
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local walkAnim = hum:LoadAnimation(WALK)
i had the same problem initially, just remember this and you are good to play 90% of all animations
local carryTrack = nil
local function doAnimations(char, equipped)
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
if equipped then
carryTrack = animator:LoadAnimation(carryAnim)
carryTrack:Play()
elseif carryTrack then
carryTrack:Stop()
carryTrack:Destroy()
end```
the main animator part of the script
I don’t think you understand how LoadAnimation() works, the animation has to be an object like a Animation Instance like a part or a humanoid not an ID.
Yo, I know you solved this, but I’m just saying, don’t use an animator, trust me. You need an animationController and it’s a whole thing, so just use the Humanoid:LoadAnimation() thing i talked about in post 4