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?

9 comments
The truth is that it is difficult to help you this incomplete script and what are the variables Alive models? Do you have the script on it?
edited the post to include the whole script.
It has an end at the end of the line of in while
That was an error, there is no end in the script.
The class gamemodes that are in ServerStorage?
If you're referring about the table of gamemodes I have defined, they are only referenced in the scripts. The object or models I want to clone are in ServerStorage.
So what do you want to clone all the models at the same time of the ServerStorage?
I've figured it out, nevermind.
The spawnGameMode () function you never call.