Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how could I check who wins a round?

Asked by 4 years ago
Edited 4 years ago

I have a leaderstats value called "Banked". Players on a team bank their coins, and when both teams have banked, whichever team has the most coins banked wins the round. How could I do this?

This is my current attempt, but the team that banked their coins last will always show as 0 coins banked.

01for i, v in pairs(Players:GetPlayers()) do
02        if v.Team == Teams.Blue then
03            totals[1] = totals[1] + v.leaderstats.Banked.Value
04        elseif v.Team == Teams.Red then
05            totals[2] = totals[2] + v.leaderstats.Banked.Value
06        end
07        wait(1)
08        v.Team = Teams.Waiting
09        v.leaderstats.Coins.Value = 0
10        wait()
11        if totals[1] > totals[2] then
12            print("Blue won")
13            showNotification:FireAllClients("Blue won!", Color3.new(0, 0, 1), 5)
14        elseif totals[2] > totals[1] then
15            print("Red won")
16            showNotification:FireAllClients("Red won!", Color3.new(0.870588, 0, 0), 5)
17        else
18            print("Tie")
19            showNotification:FireAllClients("Tie!", Color3.new(0, 0, 0), 5)
20        end
0
Line 2: Try using v.TeamColor and Teams.Blue.TeamColor instead of v.Team and Teams.Blue CyzDev 26 — 4y
0
It does the same thing. I don't think detecting the teams is the problem, it's that it doesn't update the last team when they bank their coins OfficerBrah 494 — 4y

Answer this question