I'm puzzled as to why this doesn't work. in theory it should. Did I do something wrong? It get's inside the function, because the client is displaying "Teleporting Players...".
timeRemote = game.ReplicatedStorage.timeExchange statusRemote = game.ReplicatedStorage.statusExchange advantageRemote = game.ReplicatedStorage.advantageExchange function choseGameMode() statusRemote:FireAllClients("Choosing gamemode... please wait.") pickedGameMode = gameModes[math.random(1,#gameModes)] statusRemote:FireAllClients(("The chosen gamemode is "..pickedGameMode.."!")) end function spawnGameMode() if pickedGameMode == "GameMode1" then --GameMode1 spawn local gameMode1Map = game.ServerStorage.GameMode1:Clone() gameMode1Map.Parent = game.Workspace elseif pickedGameMode == "GameMode2" then --GameMode2 spawn local gameMode2Map = game.ServerStorage.GameMode1:Clone() gameMode2Map.Parent = game.Workspace elseif pickedGameMode == "GameMode3" then --GameMode3 spawn local gameMode2Map = game.ServerStorage.GameMode1:Clone() gameMode2Map.Parent = game.Workspace end end function advantagePlayer() statusRemote:FireAllClients("Choosing Player to give an advantage to...") for i=1,#alive do if alive[i] == pickedPlayer then advantageRemote:FireClient(alive[i],"Shh... You have the Advantage!") else advantageRemote:FireClient(alive[i],"You don't have the Advantage, maybe next time.") end end wait(3) for i=1,#alive do advantageRemote:FireAllClients(" ") end end function teleportPlayers() statusRemote:FireAllClients("Teleporting Players...") if pickedGameMode == "GameMode1" then --GameMode1 teleport for i=1, #alive do print("1") alive[i].Character:MoveTo(Vector3.new(math.random(50,150), 108, math.random(150,250))) end elseif pickedGameMode == "GameMode2" then --GameMode2 teleport for i=1, #alive do print("1") alive[i].Character:MoveTo(Vector3.new(math.random(50,150), 108, math.random(-150,-250))) end elseif pickedGameMode == "GameMode3" then --GameMode3 teleport for i=1, #alive do print("1") alive[i].Character:MoveTo(Vector3.new(math.random(-50,-150), 108, math.random(-150,-250))) end end end while true do wait(4) if #game.Players:GetChildren() < 4 then --CHECK FOR PLAYERS --VARIABLES players = game.Players:GetChildren() alive = players pickedPlayer = players[math.random(1,#players)] gameModes = { "GameMode1", "GameMode2", "GameMode3" } --VARIABLES teleportPlayers() end end
Side Question: Is there a way I can optimize this instead of just checking for the value of the picked gamemode?