01 | tab = { "Player1" , "Noob" , "builderman" , "etc" } |
02 | game.Players.PlayerAdded:connect( function (plr) |
03 | stats = Instance.new( "IntValue" ,plr) |
04 | stats.Name = "leaderstats" |
05 | points = Instance.new( "IntValue" ,stats) |
06 | points.Name = "Points" |
07 | for i,v in pairs (tab) do --I'm pretty sure the error is somewhere from here to the end |
08 | Kids = game.Players:GetChildren() |
09 | if Kids = = v then |
10 | Kids.leaderstats.Points.Value = 9 |
11 | end |
12 | end |
13 | end ) |
nothing in the output and when the people in the table enter,nothing happen
In line 9 of that code snippet, you are comparing a Table (game.Players:GetChildren()
) with a a String (v
, which in this context is a member of that table tab
, of which all are Strings). That if statement will always not go through.
I assume you want to check if the player that just joined is on that list, and if so give them 9 points:
01 | tab = { "Player1" , "Noob" , "builderman" , "etc" } |
02 | game.Players.PlayerAdded:connect( function (plr) |
03 | stats = Instance.new( "IntValue" ,plr) |
04 | stats.Name = "leaderstats" |
05 | points = Instance.new( "IntValue" ,stats) |
06 | points.Name = "Points" |
07 | for i,v in pairs (tab) do |
08 | if plr.Name = = v then |
09 | points.Value = 9 -- Since I assume it is plr you're wanting to give points to, we already have their Points IntValue object. |
10 | break -- no need to continue looping if we get a match. |
11 | end |
12 | end |
13 | end ) |
Also, try to use spaces before and after all operands (including the string concatenation one: ..
) Errors sometimes popup because a phrase you intended to be separate was considered one word by the interpreter, and it also looks a little cleaner. This is not a requirement, as you code is correct without the spaces.