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

What is wrong with this?

Asked by
tumadrina 179
9 years ago
tab={"tumadrina","Person","People","etc"}
game.Players.PlayerAdded:connect(function(plr)
    stats = Instance.new("IntValue",plr) 
    stats.Name = "leaderstats"

    points = Instance.new("IntValue",stats)
    points.Name = "Points" 
    points.Value = 0 
end) 
game.Players.PlayerAdded:connect(function()
    for i,v in pairs(tab)do
        if game.Players.PlayerAdded==v then
            game.Players.PlayerAdded.Points.Value=9
        end
    end
end)

nothing in the output and the problem is I don't have 9 points

1 answer

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

You don't need two event handlers, and you're accessing an event (on line 13) and treating it like it's a player. Do this:

tab={"tumadrina","Person","People","etc"}
game.Players.PlayerAdded:connect(function(plr)
    stats = Instance.new("IntValue",plr) 
    stats.Name = "leaderstats"

    points = Instance.new("IntValue",stats)
    points.Name = "Points" 
    points.Value = 0 
    for i,v in pairs(tab)do
        if game.Players.PlayerAdded==v then
            plr.leaderstats.Points.Value = 9
        end
    end
end)


0
Thanks tumadrina 179 — 9y
Ad

Answer this question