So I want to make a last man standing round system like the ones in Horrific Housing or Breaking Point. and it goes like this: The players Join and the Intermission timer plays after that all the players deploy to a random map, Then the game starts and when all player died except for one, That one player wins the game
here’s the code that does not work
local replicatedStorage = game:GetService("ReplicatedStorage")
local status = replicatedStorage:WaitForChild("Status")
local RoundInfoStatus = replicatedStorage:WaitForChild("RoundInfoStatus")
--local inGameBool = replicatedStorage:WaitForChild("InGame")
local mapsFolder = replicatedStorage:WaitForChild("Maps")
local maps = mapsFolder:GetChildren()
local intermissionVal = 10 --The number of seconds when Intermission
local playingTeam = game.Teams.Playing
local lobbyTeam = game.Teams.Lobby
local function toMS(s)
return string.format("%02i:%02i", s/60%60, s%60)
end
game.Players.PlayerAdded:Connect(function(player)
player.Team = lobbyTeam
end)
while true do
wait(5)
--Intermission--
for i = intermissionVal,0,-1 do
wait(1)
status.Value = toMS(i)
RoundInfoStatus.Value = "Intermission"
end
--Pick a random map--
local ChosenMap = maps[math.random(1,#maps)]
local ClonedMap = ChosenMap:Clone()
ClonedMap.Parent = game.Workspace
--Deploy all players to the map--
for _, player in pairs(game.Players:GetChildren()) do
player.Team = playingTeam
local char = player.Character or player.CharacterAdded:Wait()
char.HumanoidRootPart.CFrame = CFrame.new(ClonedMap.TPPart.Position) -- Teleports
end
end
--Remove player when died--
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
print(player.Name .. " has died!")
player.Team = lobbyTeam
end)
end)
end)
--The last players to survive wins--
if #playingTeam:GetPlayers() == 1 then
local players = playingTeam:GetPlayers()
for i,v in pairs(players) do
print(v.Name)
status.Value = v.Name.." Wins!"
RoundInfoStatus.Value = ""
--wait(5)
v.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.SpawnLocation.Position)
end
--Destroy the old map--
for i,v in pairs (mapsFolder:GetChildren()) do
if game.Workspace:FindFirstChild(v.Name) then
local obj = game.Workspace[v.Name]
obj:Destroy()
end
end
for _, player in pairs(game.Players:GetChildren()) do
player.Team = lobbyTeam
end
end