How i get a Number from a Module

Hello Everyone,

I am trying to make a Round System by Spawning Enemies with a for loop but the problem is i cant get my number what i defined by a local variable from a Module

Module Script

local module = {
	
	
	["0"] = {
			["Zombie"] = 5,
			["Zombie2"] = 5,
	},
	["1"] = {
		["Zombie"] = 0,
		["Zombie2"] = 10,
	}	
}

return module

Server Script

local RoundCount = plr:FindFirstChild("leaderstats"):FindFirstChild("Round")
	
print(RoundConfig[RoundCount.Value].Zombie)   -- Error (attempt to index nil with 'Zombie')

if i Print only Round Count its a “0”

FindFirstChild(“Round”) is a IntValue

1 Like

Try doing [0] instead of [“0”]. I believe roundcount.Value is a number value while the table you made uses string numbers as keys.

1 Like

you are right!
can i change the module that i have numbers instead od strings numbers or do i have to Change RoundCount toString?

jut get rid of the keys all together so its something like,

local module = {
    {["Zombie"] = 5,["Zombie2"] = 5,},
    {["Zombie"] = 0,["Zombie2"] = 10,},
}

return module

This will make it so it’s an numeric array and assign the indexes for you but keep in mind roblox starts from 1 so to get the first value just do

RoundCount[1]
1 Like

Since your keys are strings it’s trying to index with an integer. Since there is no integer keys, the result is nil.

1 Like

In your case, since the index in your table are strings, you would need to do

print(RoundConfig[tostring(RoundCount.Value)].Zombie)
2 Likes