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

How do I award a win when there is one person left on a team?

Asked by 5 years ago
Edited 5 years ago

Im making this game in which you're on a shrinking baseplate, and you're trying to knock everyone off of it, and be the last one standing.

In this game I have 2 teams, and the one I'm focusing on is called "Player"

So, when one person is left on the team, how do I award them the win?

game.Teams.Players (Not even sure if Im doing this right)
0
just listen for the PlayerRemoved event of Team object and check if #game.Teams.Players:GetPlayers() returns 1 User#23365 30 — 5y

1 answer

Log in to vote
1
Answered by
stef0206 125
5 years ago
Edited 5 years ago
game.Teams.Players.PlayerRemoved:Connect(function(plr)
    local playerCount = #game.Teams.Players:GetPlayers()
    if playerCount == 1 then
        local winner = game.Teams.Players:GetPlayers()
        for i, v in pairs(winner) do
            v.leaderstats.win.Value = v.leaderstats.win.Value + 1
        end 
    end
end)

Might be a bit scrappy! Hope this helps!

0
that wouldn't work :/ , for starters , you are just giving the win to the 2nd to last person left standing theking48989987 2147 — 5y
0
You're right! Sorry about that! stef0206 125 — 5y
0
we want to give the win to last player when the 2nd to last player is eliminated. right now, you're giving it to the last player when he is eliminated. but you're getting there Overscores 381 — 5y
0
It would work but I see the problem, I should have fixed, do note this is NOT the most effective way, but it works stef0206 125 — 5y
Ad

Answer this question