So I want to cancel this function so when all the players die but how can I cancel a function tho?
function StartGame() ChooseGame() print(rm) game.ReplicatedStorage.PlayersAlive.Value = game.ReplicatedStorage.NumPlayers.Value for i,v in pairs(game.Players:GetChildren()) do v.Backpack.inGame.Value = "Game" end game.ReplicatedStorage.GameStatus.Value = "Game" if rm == 1 then game.ReplicatedStorage.GameStatus.Value = "Game" local WaterRunMap = game.ServerStorage.WaterRun:Clone() WaterRunMap.Parent = game.Workspace game:GetService("ReplicatedStorage").GameTime60:Fire() game:GetService("ReplicatedStorage").WaterRun:FireAllClients() wait(2.5) for i,v in pairs(game.Players:GetChildren()) do v.Character.HumanoidRootPart.CFrame = CFrame.new(-207.5, 17.5, 151.5) end for t = 60,0,-1 do game.ReplicatedStorage.GameTime.Value = t wait(1) end EndGame() Intermission() elseif rm == 2 then game.ReplicatedStorage.GameStatus.Value = "Game" local BombBombRainMap = game.ServerStorage.BombBombRain:Clone() BombBombRainMap.Parent = game.Workspace game.ServerScriptService.BombRain.Disabled = false game:GetService("ReplicatedStorage").GameTime60:Fire() game:GetService("ReplicatedStorage").BombBombRain:FireAllClients() wait(2.5) for i,v in pairs(game.Players:GetChildren()) do v.Character.HumanoidRootPart.CFrame = CFrame.new(-43, 2.5, 27) end for t = 60,0,-1 do game.ReplicatedStorage.GameTime.Value = t wait(1) end game.ServerScriptService.BombRain.Disabled = true EndGame() Intermission() elseif rm == 3 then game.ReplicatedStorage.PlayersAlive.Value = game.ReplicatedStorage.NumPlayers.Value game.ReplicatedStorage.GameStatus.Value = "Game" game:GetService("ReplicatedStorage").GameTime120:Fire() local SwordFightMap = game.ServerStorage.SwordFight:Clone() SwordFightMap.Parent = game.Workspace game:GetService("ReplicatedStorage").SwordFight:FireAllClients() wait(2.5) for i,v in pairs(game.Players:GetChildren()) do v.Character.HumanoidRootPart.CFrame = CFrame.new(2, 5, 80) end for t = 120,0,-1 do game.ReplicatedStorage.GameTime.Value = t wait(1) end EndGame() Intermission() --[[elseif rm == 4 then local PlatformRunMap = game.ServerStorage.PlatformRun:Clone() PlatformRunMap.Parent = game.Workspace if NumPlayers.Value == 2 then print("PlaceHolder") elseif NumPlayers.Value == 3 then print("PlaceHolder") elseif NumPlayers.Value == 4 then print("PlaceHolder") elseif NumPlayers.Value == 5 then print("PlaceHolder") elseif NumPlayers.Value == 6 then print("PlaceHolder") elseif NumPlayers.Value == 7 then print("PlaceHolder") elseif NumPlayers.Value == 8 then print("PlaceHolder") elseif NumPlayers.Value == 9 then print("PlaceHolder") elseif NumPlayers.Value == 10 then print("PlaceHolder") elseif NumPlayers.Value == 11 then -- Sometimes roblox's servers can go 1 player over max So this is for that player print("PlaceHolder") elseif NumPlayers.Value == 1 then print("Not Enough Players for gamemode!") print("Ending game!") PlatformRunMap:Destroy() end --]] elseif rm == 4 then --This Map is disabled Because it is a wip game.ReplicatedStorage.PlayersAlive.Value = game.ReplicatedStorage.NumPlayers.Value game.ReplicatedStorage.GameStatus.Value = "Game" local LaserTagMap = game.ServerStorage.LaserTag:Clone() LaserTagMap.Parent = game.Workspace wait(2.5) for i,v in pairs(game.Players:GetChildren()) do v.Character.HumanoidRootPart.CFrame = CFrame.new(104, 7.59996033, -35) end game:GetService("ReplicatedStorage").LaserTag:FireAllClients() wait(10) for t = 120,0,-1 do game.ReplicatedStorage.GameTime.Value = t wait(1) end EndGame() Intermission() elseif rm == 6 then --This Map is disabled Because it is a wip local SewersMap = game.ServerStorage.WIPSewers:Clone() SewersMap.Parent = game.Workspace end end
I want to cancel this function
I believe you call 'return'. This would make the function return a value of 'nil', which would cancel your function as a side effect.