Dictionary variables not creating self?

I’m currently trying out randomly generated objects, and I’m trying to get a system that generates weapons and stats. However, I keep getting the error “ServerScriptService.WeaponGenerator:9: attempt to index nil with ‘Attack’” I’ve searched around but cant find any answers to this, can anyone tell me what I’m doing wrong?

for i = 1, 30, 1 do
	weapons[tostring(i)] = {}
	weapons[i].Attack = math.random(0, 50)
	weapons[i].Durability = math.random(0, 100)
end

Because hashing requires both to be rawequal (hence NaN doesn’t work), it doesn’t account for the string-number coersion.

Why are you using tostring(i) on it?

When you create it, you are using tostring instead of a number. When you access it, you are using a number. Get rid of tostring and this should work.

Thanks to both of you for the awfully fast responses!
Responding to Blockzez, I didn’t know that you could use numbers as names for arrays, that’s why I was using tostring.