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: