Hello, so I made a intermission system following a tutorial and I would like to integrate a winner system in my script where when the last timer reach 0 (wave) all the remaining players alive (who survived the zombie wave) wins and the list of all the players who won appears. (announcement) and if no one survives it just shows “lost”
The problem is I have no clue how to make it
I want on many Dev forum but I couldn’t find any solution that could help me much…
The only thing I found was a similar post with someone having a similar problem (Can't Figure Out How to Make a Winner System) but when I tried to integrate the solution script in mine it didn’t seem to work (here is the code)
for i, player in pairs(game.Players:GetPlayers()) do
local winners = table.concat(playersInRound,", ")
player.PlayerGui.MapNameGui.TextLabel.Text = "Winners: "..winners
end
(I had a similar concept idea from Survive the Night but maybe Gui version)
Thank You for taking the time to read!
Here is my Intermission system code:
ServerStorage = game:GetService("ServerStorage")
ReplicatedStorage = game:GetService("ReplicatedStorage")
Players = game:GetService("Players")
Maps = ServerStorage:WaitForChild('Maps'):GetChildren()
Status = ReplicatedStorage:WaitForChild('Status')
while true do
--Intermission
local Countdown = 20 -- intermission
repeat wait(1)
Countdown = Countdown - 1
Status.Value = 'Intermission : '..Countdown
until Countdown <= 0
--Choose the map.
Status.Value = 'Game Starting'
local ChosenMap = Maps[math.random(1, #Maps)]:Clone()
local Spawns = ChosenMap:FindFirstChild('Spawns'):GetChildren()
local RandomSpawn = Spawns[math.random(1, #Spawns)]
wait(3) -- little pause, make this as long as you want
ChosenMap.Parent = workspace
Status.Value = 'Teleporting players.'
wait(3) -- little pause
--teleport the players
local playersInRound = {} -- track alive players
local connections = {} -- store connections to disconnect later
for _, Player in pairs(Players:GetChildren())do
if Player.Character and Player.Character:FindFirstChild('Humanoid') then
Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
table.insert(playersInRound, Player) -- add all players to table
connections[Player.Name] = Player.Character.Humanoid.Died:Connect(function() -- remove player from list on death
table.remove(playersInRound, table.find(playersInRound, Player))
end)
end
end
connections["Removing"] = game.Players.PlayerRemoving:Connect(function(player) -- remove player from list if they leave
local ind = table.find(playersInRound, player)
if ind then
table.remove(playersInRound, ind)
end
end)
Countdown = 15 -- Starting Round In
repeat wait(1)
Countdown = Countdown - 1
Status.Value = 'Starting Round in: '..Countdown
until Countdown <= 0
Countdown = 15 -- Wave Round
repeat wait(1)
Countdown = Countdown - 1
Status.Value = 'Survive the Zombies: '..Countdown
until Countdown <= 0 or #playersInRound == 0
Status.Value = 'Door Open'
Countdown = 15 -- Wave intermission
repeat wait(1)
Countdown = Countdown - 1
Status.Value = 'Next Wave In'..Countdown
until Countdown <= 0 or #playersInRound == 0
--Kill the players
for _, connection in pairs(connections) do -- disconnect connections to prevent memory leaks
connection:Disconnect()
end
for _, Player in pairs(playersInRound)do
Player:LoadCharacter()
end
ChosenMap:Destroy()
Status.Value = 'Round Ended, waiting for new game.'
wait(4) -- little pause
end