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

Why won't this leaderboard work?

Asked by 10 years ago
game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("leaderstat",player)
    leaderstats.Name = "leaderstats"

    local points = Instance.new('IntValue',leaderstats)
    points.Name = "Points" --Name of stat
    points.Value = "0"

end)

2 answers

Log in to vote
1
Answered by 10 years ago

There :)

--Made by GuardainDev
function Entered(player)
    wait()

    if player:findFirstChild("leaderstats") ~= nil then
        player.leaderstats:remove()
    end

    stats = Instance.new("IntValue")
    stats.Parent = player
    stats.Name = "leaderstats"

    money = Instance.new("IntValue")
    money.Parent = stats
    money.Name = "Points"
    money.Value = 0

end

game.Players.PlayerAdded:connect(Entered)

c = game.Players:GetChildren()
for i=1, #c do
    Entered(c[i])
end

Ad
Log in to vote
0
Answered by 10 years ago

Try making leaderstats and points not local. Also, slightly change your code to this:

--Make sure your script is a local script
Player = game.Player.LocalPlayer
game.Players.PlayerAdded:connect(function(player)
    leaderstats = Instance.new("leaderstat",Player) --Player now has a variable set, so that should work
    leaderstats.Name = "leaderstats"

    points = Instance.new('IntValue',leaderstats)
    points.Name = "Points" --Name of stat
    points.Value = "0"

end)

If it doesn't work let me know. I'm no leaderstats expert after all.

Answer this question