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
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.