bad argument #1 to 'pairs' (table expected, got string)

Hello keep getting this error message when using the in pairs loop.

bad argument #1 to ‘pairs’ (table expected, got string)

The table
[lua]
Weapons.Test =
{
[“G3SG1”] = “weapon_ttt_g3”,
[“M4A1”] = “weapon_ttt_m16”
}
[/lua]
and the loop
[lua]
for name, value in pairs( Weapons.Test ) do[/lua]

Seen this same thing work on another addon.

This should fiix it

If you want to get that to work you show define the weapons table


 
Weapons = {}

Weapons.Test = 
{
	["G3SG1"] = "weapon_ttt_g3",
	["M4A1"] = "weapon_ttt_m16"
}

for name,value in pairs(Weapons.Test) do 
--code
end


If I hadn’t done that then I would of got an error saying something like “Weapons is undefined” but for some reasons gmod is complaining that it is not a a table but a string.

print(Weapons.Test) and see what it spits out