I have no clue why it’s happening, but the code looks fairly normal to me. The object I’m referring to here is a non-humanoid model (uses AnimationController).
local function Light(Object,Type)
local ClassObject = nil
local Animation = nil
if Object.Name == "LightL" then
ClassObject = game.Workspace["Core scripts"].Lights.Animations.Left:WaitForChild(tostring(Type))
elseif Object.Name == "LightR" then
ClassObject = game.Workspace["Core scripts"].Lights.Animations.Right:WaitForChild(tostring(Type))
local Animation = Object.AnimationController.Animator:LoadAnimation(ClassObject)
until LightModeActivated.Value == false
local connection = task.defer(Light,object,Type)
Error occurs on this line:
Could you provide the error itself or if there is any error at all?
EDIT: Oh it’s on title, kinda of a rogue approach to giving the error x_x
Error is listed above.
This line seems to be causing it.
Have you done any debugging such as printing what
ClassObject, before the line that is creating the error.
Yes, I have. It properly registers it. The error, however, still persists.
Maybe try actually creating an Instance of the animation through script and loading the animation that way. I know that is quite a length task, but it might reveal more of the problem.
Is it really necessary tho? I think the code is fine or there’s something that disrupts it. That shouldn’t really be a barrier.
Does anyone have any other ideas?
the script doesn’t directly target the actual humanoid, its directing to something called “Animator”
fix it so it targets the humanoid directly, not the “Animator”
The object is a non-humanoid object (a LED light). It uses AnimationController instead.
Humanoid is deprecated, this is the new standard to loading animation
I mean it’s worth a try?
local x = Instance.new("Animation")
x.AnimationID = id
-- Written in pseudo so might be inaccurate
It might seem unnecessary, but your setup environment is also very unclear from what you have provided.
i’ve never understood that, am i just being stupid or something?
Update: I gave this a try anyway to see if it would do the job. It ACTUALLY worked! Thanks for recommending this.
Well that now reveals that it’s likely just not organised properly, at least your explorer tree.
That’s an assumption, but it would be nice if we can see the Explorer.
Try writing “local ClassObject = nil” as “local ClassObject” since what I think is happening, is that the LoadAnimation is prioritizing your first “local ClassObject = nil” while ignoring the other ClassObject.