Make it win on my Color Block game

How can I make it so you can win on my Color Block game.

I added a Coins leaderstat and a Wins leaderstat.

I need to reward the players with coins and 1 win when there is 1 player left.

Code:

Main:
repeat
wait(1)
StartRound()
until game.Workspace.PlayersAlive.Value == 0
for i,v in pairs (game.Players:GetPlayers()) do
if v.Alive == true then
changeColourText(v…" has won the game!")
v.leaderstats.Wins.Value = v.leaderstats.Wins.Value + 1
v.Alive = false

StartRound() Function:

local function StartRound()
wait()
local randomColour = game.Workspace.Colours:GetChildren()[math.random(1, 6)]
print (randomColour)
changeColour(randomColour)
Countdown()
local colours = game.Workspace.Colours:GetChildren()
for i,v in pairs (colours) do
v.Parent = game.ReplicatedStorage
randomColour.Parent = workspace.Colours
end
wait(3)
for i,v in pairs (colours) do
v.Parent = workspace.Colours
end
end

Countdown Function:

local function Countdown()
changeCountdown(“5”)
wait(1)
changeCountdown(“4”)
wait(1)
changeCountdown(“3”)
wait(1)
changeCountdown(“2”)
wait(1)
changeCountdown(“1”)
wait(1)
changeCountdown(“GO!”)

end

Game:

Try the following, when executing the code for the color block function. Please note that you will need a table with the players in-game for that.

repeat
-- Random code that happens each round in Color block
until #players == 1
print(players[1])

Make sure you remove players from the table when they die! If you need any help, I would be happy to respond.

P.S. Change the topic to #help-and-feedback:scripting-support :grin:

Done and thank you! :smiley:

lol.

Alright, if that solved your inquiries, make sure to mark my reply as a solution so other members of the DevForum can see that the topic has been solved. Have a good day! :grin:

Oh yeah I forgot lol. Sorry I marked it now.