So I'm making a game with a script that teleports players to different maps using math.random. The problem is, the outcome is always the same number, making the same map load over and over again.. How do I fix this? Thanks for stopping by to read this!
local Map1 = game.Lighting.Map1
local Map2 = game.Lighting.Map2
local Map3 = game.Lighting.Map3
local Map4 = game.Lighting.Map4
local Map5 = game.Lighting.Map5
while true do
msg = Instance.new("Message")
msg.Parent = nil
msg.Parent = game.Workspace
msg.Text = "Welcome to Zombie Survival! Choosing a map!"
wait(1)
msg:remove()
math.randomseed(tick())
for _ = 1, 5 do
ChooseMap = math.random(1,5)
if ChooseMap == 1 then
map1z = game.Lighting.Map1:clone()
map1z.Parent = game.Workspace
msg = Instance.new("Message")
msg.Parent = nil
msg.Parent = game.Workspace
msg.Text = "Loading map please wait."
wait(0.5)
msg.Text = "Loading map please wait.."
wait(0.5)
msg.Text = "Loading map please wait..."
wait(0.5)
msg.Text = "Loading map please wait."
wait(0.5)
msg.Text = "Loading map please wait.."
wait(0.5)
msg.Text = "Loading map please wait..."
wait(1)
msg.Text = "Map loaded! Teleporting players..."
msg:remove()
wait(1)
for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
if plr.Character then
plr.Character:MoveTo(Vector3.new(14.31, 1.61, -151.635))
wait(20)
msg = Instance.new("Message")
msg.Parent = nil
msg.Parent = game.Workspace
msg.Text = "Game end... Intermission!"
wait(1)
for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
if plr.Character then
plr.Character:MoveTo(Vector3.new(1.915, 915.46, -26.68))
msg:remove()
map1z:Destroy()
wait(10)
if ChooseMap == 2 then
map2z = game.Lighting.Map2:clone()
map2z.Parent = game.Workspace
msg = Instance.new("Message")
msg.Parent = nil
msg.Parent = game.Workspace
msg.Text = "Loading map please wait."
wait(0.5)
msg.Text = "Loading map please wait.."
wait(0.5)
msg.Text = "Loading map please wait..."
wait(0.5)
msg.Text = "Loading map please wait."
wait(0.5)
msg.Text = "Loading map please wait.."
wait(0.5)
msg.Text = "Loading map please wait..."
wait(1)
msg.Text = "Map loaded! Teleporting players..."
msg:remove()
wait(1)
for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
if plr.Character then
plr.Character:MoveTo(Vector3.new(23.1, 140.98, -331.42))
wait(20)
msg = Instance.new("Message")
msg.Parent = nil
msg.Parent = game.Workspace
msg.Text = "Game end... Intermission!"
wait(1)
for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
if plr.Character then
plr.Character:MoveTo(Vector3.new(1.915, 915.46, -26.68))
msg:remove()
map2z:Destroy()
wait(10)
if ChooseMap == 3 then
map3z = game.Lighting.Map3:clone()
map3z.Parent = game.Workspace
msg = Instance.new("Message")
msg.Parent = nil
msg.Parent = game.Workspace
msg.Text = "Loading map please wait."
wait(0.5)
msg.Text = "Loading map please wait.."
wait(0.5)
msg.Text = "Loading map please wait..."
wait(0.5)
msg.Text = "Loading map please wait."
wait(0.5)
msg.Text = "Loading map please wait.."
wait(0.5)
msg.Text = "Loading map please wait..."
wait(1)
msg.Text = "Map loaded! Teleporting players..."
msg:remove()
wait(1)
for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
if plr.Character then
plr.Character:MoveTo(Vector3.new(23.1, 220.36, 477.16))
wait(20)
msg = Instance.new("Message")
msg.Parent = nil
msg.Parent = game.Workspace
msg.Text = "Game end... Intermission!"
wait(1)
for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
if plr.Character then
plr.Character:MoveTo(Vector3.new(1.915, 915.46, -26.68))
msg:remove()
map3z:Destroy()
wait(10)
if ChooseMap == 4 then
map4z = game.Lighting.Map1:clone()
map4z.Parent = game.Workspace
msg = Instance.new("Message")
msg.Parent = nil
msg.Parent = game.Workspace
msg.Text = "Loading map please wait."
wait(0.5)
msg.Text = "Loading map please wait.."
wait(0.5)
msg.Text = "Loading map please wait..."
wait(0.5)
msg.Text = "Loading map please wait."
wait(0.5)
msg.Text = "Loading map please wait.."
wait(0.5)
msg.Text = "Loading map please wait..."
wait(1)
msg.Text = "Map loaded! Teleporting players..."
msg:remove()
wait(1)
for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
if plr.Character then
plr.Character:MoveTo(Vector3.new(23.1, -200.77, 477.16))
wait(20)
msg = Instance.new("Message")
msg.Parent = nil
msg.Parent = game.Workspace
msg.Text = "Game end... Intermission!"
wait(1)
for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
if plr.Character then
plr.Character:MoveTo(Vector3.new(1.915, 915.46, -26.68))
msg:remove()
map4z:Destroy()
wait(10)
if ChooseMap == 5 then
map5z = game.Lighting.Map1:clone()
map5z.Parent = game.Workspace
msg = Instance.new("Message")
msg.Parent = nil
msg.Parent = game.Workspace
msg.Text = "Loading map please wait."
wait(0.5)
msg.Text = "Loading map please wait.."
wait(0.5)
msg.Text = "Loading map please wait..."
wait(0.5)
msg.Text = "Loading map please wait."
wait(0.5)
msg.Text = "Loading map please wait.."
wait(0.5)
msg.Text = "Loading map please wait..."
wait(1)
msg.Text = "Map loaded! Teleporting players..."
msg:remove()
wait(1)
for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
if plr.Character then
plr.Character:MoveTo(Vector3.new(-655.39, 220.36, 477.16))
wait(20)
msg = Instance.new("Message")
msg.Parent = nil
msg.Parent = game.Workspace
msg.Text = "Game end... Intermission!"
wait(1)
for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
if plr.Character then
plr.Character:MoveTo(Vector3.new(1.915, 915.46, -26.68))
msg:remove()
map5z:Destroy()
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end

1 comment
I noticed I made two small errors with the Map cloning on 4 and 5. Even though I fixed this, The same thing still happens..