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

How can I get a certain team and award points to that team?

Asked by 9 years ago

So the points leaderboard I am awarding points to is called points. I added this but noticed it added points to all players, not just one team. This is how I thought I did it. Please correct me.

plr = game.Players:GetPlayers(); for i = 1, #plr do; plr[i].leaderstats.Points = plr[i].leaderstats.Points + 10; end;

My point is how can I change this so it only awards points to a certain team?

1 answer

Log in to vote
1
Answered by 9 years ago

I prefer for i,v in pairs:

for i,v in pairs(game.Players:GetPlayers()) do
    if v.TeamColor == game.Teams["TEAMNAME"].TeamColor then
        v.leaderstats.Points.Value = v.leaderstats.Points.Value + 10 --You need to get to THE VALUE not just the object
    end
end

Whenever you use BoolValue, StringValue, IntValue, etc always, ALWAYS have a .Value when you are after what that value is set to.

Example:

StringValue's value is "Hi there!" and I want to change it:

game.Workspace.StringValue.Value = "Changed"
1
You should probably use :GetPlayers() instead of :GetChildren() BlueTaslem 18071 — 9y
0
Thanks you so much man, I appreciate it! ;) laughablehaha 494 — 9y
0
Whoops, didn't know I used :GetChildren() sorry! lightpower26 399 — 9y
Ad

Answer this question