That's a very important clarification! Let's make sure the behavior matches exactly what you want.
Based on the latest script I provided, here's how the win condition currently works and how to adjust it to your new specification:
-
Does the game end when the round ends?
- Yes. The
endRound() function is called when the ROUND_TIME expires, or if the number of runners drops to 1 or 0 (meaning taggers won early). When endRound() is called, gameInProgress is set to false, maps are cleaned up, and players are teleported back to the lobby. The game then enters an intermission phase before starting a new round.
-
Does everyone who is still a runner at that time get a +1 win?
- Currently, no. In the script I provided, the win condition for runners specifically checks if
survivorCount == 1. This means only the single last runner gets a win if they manage to survive the entire round without anyone else. All remaining runners (survivorCount >= 1) do get 500 coins.
How to Adjust for "All Remaining Runners Get a Win"
To make it so everyone who is still a runner at the end of the round (when the timer runs out) gets a +1 win, you need to make a small change in the endRound function within your GameManager script.
Locate this section in your GameManager script:
-- Inside the endRound() function:
-- Calculate Survivors and Award Wins/Coins
local survivorCount = 0
local survivorsList = {}
for player, _ in pairs(runners) do
table.insert(survivorsList, player)
survivorCount = survivorCount + 1
end
if survivorCount >= 1 then
for _, survivor in ipairs(survivorsList) do
survivor.leaderstats.Coins.Value = survivor.leaderstats.Coins.Value + 500
-- If it's 1 survivor specifically, award a win
if survivorCount == 1 then -- <-- THIS IS THE LINE TO CHANGE
survivor.leaderstats.Wins.Value = survivor.leaderstats.Wins.Value + 1
end
end
end
Change it to this:
-- Inside the endRound() function:
-- Calculate Survivors and Award Wins/Coins
local survivorCount = 0
local survivorsList = {}
for player, _ in pairs(runners) do
table.insert(survivorsList, player)
survivorCount = survivorCount + 1
end
if survivorCount >= 1 then -- If there's at least one runner left
for _, survivor in ipairs(survivorsList) do
survivor.leaderstats.Coins.Value = survivor.leaderstats.Coins.Value + 500
-- Now, all remaining runners (if there's at least one) get a win
survivor.leaderstats.Wins.Value = survivor.leaderstats.Wins.Value + 1
end
end
Explanation of the change:
I removed the if survivorCount == 1 then check specifically for awarding the win. By placing the survivor.leaderstats.Wins.Value = survivor.leaderstats.Wins.Value + 1 line directly inside the for loop that iterates through survivorsList (which is already inside if survivorCount >= 1 then), every player who is still a runner when the round ends will now receive a win, in addition to their 500 coins.
With this modification, your game will behave exactly as you described for the runner win condition!