Best way to randomize

Hi,
Remember to set the seed when using math.random(). I’d recomend you use tick() as a seed. The other option is use the Random datatype, which already sets the seed for you
(See: Random | Documentation - Roblox Creator Hub)
By setting a seed you get a better randomness.

1 Like

when I printed local map = AvailableMaps[math.random(1,#AvailableMaps)] it displayed the name of the map (TestMap3)

That should be happening. Add a table.remove(1#AvailableMaps). Add a print after this. print(“Map Removed”). I think you’re better off getting help from someone else for the table.remove.

1 Like

I got an error message " [Expected ‘)’ (to close ‘(’ at column 16), got ‘#’]

what line is that, 30 character

local map = AvailableMaps[math.random(1,#AvailableMaps)] I think it’s talking about this

your code should look like this.

local AvailableMaps = Maps:GetChildren()
    
local map = AvailableMaps[math.random(1,#AvailableMaps)]

table.remove(1,#AvailableMaps)
print("Map removed")
1 Like

wait nvm table.remove(1,#AvailableMaps) didnt have a comma

would remove be inside the if statement or right after the table is created?