Animations don't get loaded

I’m making a new gun system and the code won’t load the animations!

Code (Local):

local function LoadAnimations()
	for i,v in ipairs(Settings.Anims) do
		local a = Instance.new("Animation", script)
		
		if not v == nil or 0 then
			a.AnimationId = "rbxassetid://"..v
		else
			a.AnimationId = "rbxassetid://5345347375" -- random numbers
		end
		
		Anims[i] = Humanoid.Animator:LoadAnimation(a)
		
		print(i)
	end
	
	for i,v in ipairs(Settings.Anims2) do
		local a = Instance.new("Animation", script)
		
		print(i)
		
	    if not v == nil or 0 then
			local a = Instance.new("Animation", script)

			a.AnimationId = "rbxassetid://"..v

			Anims[i] = Humanoid.Animator:LoadAnimation(a)
		else
			Anims[i] = nil
		end
	end
end

The i dosn’t get printed.

Thanks!

Probably something wrong with the Settings.Anims

1 Like

I don’t think It’s the table:

return {
	GunType = "Pistol", -- Automatic, Sniper, Shotgun, Pistol
	Ammo = 33, -- Mag Size
	Damage = 20, -- Damage
	Velocity = 1000, -- Velocity from the Bullet
	Range = math.huge, -- Better change Velocity bc when they reach the limit the bullets just stop flying and just stay where they are
	HeadshotMultiplier = 2, -- Damge Multipler by Headshot
	EquipTime = 1.5,
	ReloadTime = 3,
	-- Animations --
	Anims = {
		Idle = 9350750887, -- required
		Shoot = 0, -- required
	},
	Anims2 = {
		Equip = 0, -- not required
		Unequip = 0, -- not required
		Idle2 = 0, -- not required
		Recoil = 0, -- just for sniper for now
	}
}

Try deleting the if statements and see if it loads or errors. It might also be that the for loop isn’t running because of some reason (happens to me sometimes). I’m on mobile so I can’t really check.

1 Like

Ohh i fixed. i used the wrong pairs

1 Like