Animation Table indexing nil

So recently, I have been coding a gun system and I am facing a problem that irritates me a lot and that’s this error:
ReplicatedStorage.mainFrame.modules.mainModule:70: attempt to index nil with 'idle'

and here’s the code, to sum up. It’s a code to create animations and their names to be stored in a table automatically. Here:

for i,v in self.settings.anims do
		local anim = Instance.new("Animation")
		anim.Name = i
		anim.AnimationId = v
--error here self.loadedAnims[anim.Name] = self.vm:WaitForChild("Humanoid").Animator:LoadAnimation(anim)
	end

So basically it takes the animation id’s from a (setting) table such as this:

	anims = {
		--["equip"] = "rbxassetid://0";
		["idle"] = "rbxassetid://1"; <-- this one, I have to remove the actual animation ids
		--["fire"] = "rbxassetid://0";
		--["reload1"] = "rbxassetid://0";
		--["reload2"] = "rbxassetid://0";
		--["inspect"] = "rbxassetid://0";
		--["unequip"] = "rbxassetid://0";
		
		--["aimIdle"] = "rbxassetid://0";
		--["aimFire"] = "rbxassetid://0";
	};

let’s break down a bit (for anyone who doesn’t understand)

so basically the code will take the data from this → loop it through → create an animation → name it/give it animation id → stores in the loaded animations table (and loads it in the model)

Now I have no IDEA how does this doesn’t work. Take me days and still haven’t figured out why.

Also here are some things to remind you: Animation ids is valid and it’s mine, doesn’t use any VPN, etc.

Can we see where loadedAnims is defined? I believe everything else is correct

function mainModule.new(wep)
	local self = {}
	
	self.loadedAnims = {} -- loaded anims is defined here
	self.springs = {}
	self.lerpValues = {}
	self.ammo = {} -- per weapon

	self.lerpValues.aim = Instance.new("NumberValue")
	self.lerpValues.equip = Instance.new("NumberValue")
	self.lerpValues.equip.Value = 1

	self.springs.walkCycle = spring.create()
	self.springs.sway = spring.create()
	self.springs.fire = spring.create()

	self.canFire = true
	
	return setmetatable(self, fpsMT)
end

I assume fpsMT has an __index pointing to a table containing the settings, right? (I’m asking because settings isn’t defined in the constructor)


How/Where is the method that’s running the code, called? The issue is that self.loadedAnims is seen as nil, which means whatever method being ran is likely not defined within fpsMT’s __index

no, Settings is on the addon of this:

And yes fpsMT has indexing

Does it point to the mainModule table, or something else? Sorry that I’m asking for a lot; I just want to get the full picture of where everything is being defined

Yep, it does point back to the mainModule table

All I can think of is something potentionally setting the property to nil, but there’s nothing I can see that would make it nil. Do the other properties (like springs) exist at the looping point? Or is it just the loadedAnims table missing?

I don’t think springs is the reason why it is nil. Normally when I use this code over and over again it’s still working as pie
But now it just stuck there.