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

How can i give points to every player in a certain team?

Asked by 8 years ago

All im trying to do is give points to the every player in the winning team. I thought it should be simple, but i guess not. Below, i used the blue team as an example in my script. I believe the script is not working because the players in a team would act as a table, but im not quite sure. Would anyone happen to know how i could fix this to get it working properly? Thanks! ;)

Script:

1local BlueTeamPlayers = game.Teams.Blue:GetPlayers()
2 
3    if BlueWins == true then
4        status.Value = "The Winner is the Blue Team!"
5BlueTeamPlayers.leaderstats.Money.Value = BlueTeamPlayers.leaderstats.Money.Value + 10
6        wait(8)
7    end

1 answer

Log in to vote
2
Answered by 8 years ago
Edited 8 years ago
01BlueTeam = game:GetService("Teams"):FindFirstChild("Blue")
02Players = game:GetService("Players"):GetChildren() --Get all players
03 
04if BlueWins == true then
05    status.Value = "The Winner is the Blue Team!"
06    for i=1, #Players do --Loop through all players
07        if Players[i].Team == BlueTeam then --If the player is on the winning team then
08            Players[i].leaderstats.Money.Value = Players[i].leaderstats.Money.Value + 10 --Reward
09        end
10    end
11    wait(8)
12end
Ad

Answer this question