Best way to select maps

I have been making a map selecting script but I noticed that some maps may be repeated more than other maps and I am using math.random() for this function.

I thought putting the map names in table and checking if the name is in table to decide if to load in the map or choose new one but I would still would love to hear your ideas!

1 Like

Random is perfect for getting random values since it’s built with the use of seeds so the same map won’t get selected more than the others as easily as math.random().

All random number generators are built using seeds. The only thing that was changed is the algorithm as it produced poor pseudorandom numbers.

@fungamer153 The only issue I can think of is that you are using math.random() elsewhere in your game and math.random() is a shared random object. Put simply you will not get a fair distribution between map selection because calling math.random() changes its internal state which is then used to create the next pseudorandom number.

Swap to using Random | Documentation - Roblox Creator Hub so that you are not using the shared random.

1 Like

So you would put all the map names in order in a table(with the exact name of the map):

local Table = {"lol", "morelol", "evenmorelol"}

Then to select a map you would do

local map = Table[math.Random(1, #Table)]
"thing you stored the map in"[map]:Clone().Parent = workspace