gm = game.Workspace.GMstat.Intermission

while true do
ToMapOne = CFrame.new(-2, 20.5, -50)
ToMapTwo = CFrame.new(-27, 69.5, 18)
ToSpawn = CFrame.new(277.5, 1.5, -206.5)
mapc = game.Workspace.MapNum.Value
wait(29)
gm.Name = "Game In Progress"
for i, player in ipairs(game.Players:GetChildren()) do
   if player.Character and player.Character:FindFirstChild("Torso") then
	mapc.Value = (math.random(2))
	wait(1)
	if mapc.Value == 1 then
	  print(mapc.Value)
      player.Character.Torso.CFrame = ToMapOne + Vector3.new(0, i * 5, 0)
      player.TeamColor = game.Teams["Playing"].TeamColor
		for i, m1 in ipairs(game.Workspace.MapOne:GetChildren()) do
    m1.Transparency = 0
    m1.CanCollide = true
end
	    end 
	if mapc.Value == 2 then
		print(mapc.Value)
		player.Character.Torso.CFrame = ToMapTwo + Vector3.new(0, i * 5, 0)
		player.TeamColor = game.Teams["Playing"].TeamColor
		for i, m2 in ipairs(game.Workspace.MapTwo:GetChildren()) do
    m2.Transparency = 0
    m2.CanCollide = true
end
	end 
	end  
end
wait(60)
gm.Name = "Intermission"
for i, m1 in ipairs(game.Workspace.MapOne:GetChildren()) do
    m1.Transparency = 1 
    m1.CanCollide = false
end
for i, m2 in ipairs(game.Workspace.MapTwo:GetChildren()) do
    m2.Transparency = 1 
    m2.CanCollide = false
end
for i, player in ipairs(game.Players:GetChildren()) do
      if player.Character and player.Character:FindFirstChild("Torso") then
           player.TeamColor = game.Teams["Lobby"].TeamColor
           player.Character.Torso.CFrame = ToSpawn + Vector3.new(0, i * 5, 0)
end
     end
end

This script works fine for the most part, but the only problem is that when there are multiple people in the game all the script seems to generate a different number in mapc for each player, resulting in multiple numbers calling for multiple maps to be loaded. How can I fix it so that the script only chooses one number?

2 comments

0

Why do you use ipairs? It's ugly af....

0

What's the alternative?