Random doesn't work

I have 2 maps in the game and I want the maps to appear randomly every round. but during the game, only one map appears all the time. I could fix it myself, but I don’t have much time to solve this problem, so I’m asking for your help

You gave no code. Also, try using Random.new instead?

you could just use math.random(1,2) or another way like that

I think that you could make the first map there is be represented as a one and then the second map as a two and then you do math.round(math.random(1,2)) to get a number that is a one or two, and then if that number is one, you spawn map number one, but if it is two, then you spawn map 2.

map1 = --the first map you have
map2 = --the second map you have
local number = math.round(math.random(1,2))
if number == 1 then
    --Spawn the first map
else if number == 2 then
    --Spawn the second map
end

I don’t know the method you use to spawn the map but hopefully you find my code useful for it.

edit: oops I replied to wrong person

1 Like

You need to move choosenmap into the function. It only runs at the start of the code. So it picks one random map, then it uses the same map every time after that since the variable never changes.

1 Like