I am replacing the default Animate
script with a new one. I have new animations as well. The problem is that when I try to Load the animations, the LocalScript
says attempt to call a nil value
. This roughly what it looks like. Here is the script:
-- Loaded Animations local Idle = LoadAnimation(script.IdleAnim) local Running = LoadAnimation(script.RunningAnim) -- Function to load animation function LoadAnimation(animation) return Animator:LoadAnimation(animation) end
Just so you know, Animator is defined.
Any Ideas?
-- Function to load animation function LoadAnimation(animation) return Animator:LoadAnimation(animation) end -- Loaded Animations local Idle = LoadAnimation(script.IdleAnim) local Running = LoadAnimation(script.RunningAnim)
As you probably know, scripts run from top to bottom, that means line 1, then line 2, then line 3, ...
If you create variable X at line 4, you can't print(X) at line 3 since at that time line 4 has not yet been run, same in your case, lines 2 and 3 where you create the variables were trying to run a function LoadAnimation that is going to be created on line 6.