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 7 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:

local BlueTeamPlayers = game.Teams.Blue:GetPlayers()

    if BlueWins == true then
        status.Value = "The Winner is the Blue Team!"
BlueTeamPlayers.leaderstats.Money.Value = BlueTeamPlayers.leaderstats.Money.Value + 10
        wait(8)
    end

1 answer

Log in to vote
2
Answered by 7 years ago
Edited 7 years ago
BlueTeam = game:GetService("Teams"):FindFirstChild("Blue")
Players = game:GetService("Players"):GetChildren() --Get all players

if BlueWins == true then
    status.Value = "The Winner is the Blue Team!"
    for i=1, #Players do --Loop through all players
        if Players[i].Team == BlueTeam then --If the player is on the winning team then
            Players[i].leaderstats.Money.Value = Players[i].leaderstats.Money.Value + 10 --Reward
        end
    end
    wait(8)
end
Ad

Answer this question