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

How increase leaderstats of all players on a specific team?

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

3 comments

0

have you put some prints in between to make sure the code actually runs?

0

Yes

0

BrickColor.new gave me trouble in the past. Try replacing line 2 with: if v.TeamColor == Color3.fromRGB(196, 40, 28) then

1 answer

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

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