"invalid argument #2 to 'random' (interval is empty)"

I don’t know how this is happening. any similar posts I found are relating to positions rather than tables.

my code is:

local gamemodes = {
	Bloxers = "Bloxers",
}
local ChosenGamemode = gamemodes[math.random(1, #gamemodes)]

and printing the number of gamemodes outputs 0? and then trying to set it to a specific number just gives me an invalid 1 of gamemodes??? please help

This is because gamemodes is a dictionary here, and not an array.

how would I make it an array? do I just remove the Bloxers = part?

Maybe one of these would help:

1 Like

Here’s a quick answer:

The key you set to the value in the gamemodes table is unnecessary, you can just convert it to an array:

local gamemodes = {
	"Bloxers",
}
1 Like