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

How increase leaderstats of all players on a specific team?

Asked by 4 years ago

How do you increase a leaderstat of all players on a specific team? In my game all members of the "Bright red" team is supposed to recieve 150 XP when they win the game, but it is not working.

for i,v in pairs(game.Players:GetPlayers()) do
    if v.TeamColor == BrickColor.new("Bright red") then
v.leaderstats.XP.Value = v.leaderstats.XP.Value + 150
0
have you put some prints in between to make sure the code actually runs? Nogalo 148 — 4y
0
Yes TheCannibalFromMars 7 — 4y
0
BrickColor.new gave me trouble in the past. Try replacing line 2 with: if v.TeamColor == Color3.fromRGB(196, 40, 28) then nikoviking 236 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

The code looks fine, but I think you're missing two ends. The final code would look like this:

for i,v in pairs(game.Players:GetPlayers()) do
if v.TeamColor == BrickColor.new("Bright red") then
v.leaderstats.XP.Value = v.leaderstats.XP.Value + 150
end
end
Ad

Answer this question