Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 comment

0

just listen for the PlayerRemoved event of Team object and check if #game.Teams.Players:GetPlayers() returns 1

1 answer

✓ Accepted answer
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!

4 comments

0

that wouldn't work :/ , for starters , you are just giving the win to the 2nd to last person left standing

0

You're right! Sorry about that!

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.