Here I have some code for loading a random map. Every time I launch the server, it loads map #2 (there are 5).
function loadMap(x) local maps = Maps:GetChildren() for i = 1, #maps do if maps[i].Value == x then print(maps[i].MapName.Value) maps[i].Model.Parent = game.Workspace end end end function loadRandomMap() math.randomseed(tick()) local mapNum = math.random(Options.Maps.Value) if mapNum == System.CurrentMap.Value then math.randomseed(tick()) local mapNum = math.random(Options.Maps.Value) end System.CurrentMap.Value = mapNum loadMap(mapNum) end
Don't call math.randomseed(tick()) in your function. Just call it at the top of your script or else it will choose the same number over and over.
math.randomseed(tick()) --moved it to the start of your script function loadMap(x) local maps = Maps:GetChildren() for i = 1, #maps do if maps[i].Value == x then print(maps[i].MapName.Value) maps[i].Model.Parent = game.Workspace end end end function loadRandomMap() local mapNum = math.random(Options.Maps.Value) if mapNum == System.CurrentMap.Value then local mapNum = math.random(Options.Maps.Value) end System.CurrentMap.Value = mapNum loadMap(mapNum) end
local Updates = 10000 local seeder = coroutine.create( function() for int = 1, Updates do math.randomseed(tick()) coroutine.yield() end end) coroutine.resume(seeder)--Use this line of code everytime you want to get a random number
Try this instead:
local Updates = 10000 local seeder = coroutine.create( function() for int = 1, Updates do math.randomseed(tick()) coroutine.yield() end end) function loadMap(x) local maps = Maps:GetChildren() for i = 1, #maps do if maps[i].Value == x then print(maps[i].MapName.Value) maps[i].Model.Parent = game.Workspace end end end function loadRandomMap() coroutine.resume(seeder) local mapNum = math.random(Options.Maps.Value) if mapNum == System.CurrentMap.Value then coroutine.resume(seeder) local mapNum = math.random(Options.Maps.Value) end System.CurrentMap.Value = mapNum loadMap(mapNum) end