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

Any Help? Leaderboard Error [SOLVED]

Asked by 10 years ago

Hi, I'm relatively new to ROBLOX coding, and I was making a simple Leaderboard which includes "Money" as a stat. I don't know what's wrong with my design, as it is the same as in the ROBLOX Wiki, but in a less compact way, so I understand it better

function CreateStats(Player)

    local Stats = Instance.new("IntValue")
    Stats.Parent = Player
    Stats.Name = "Leaderstats"

    local Cash = Instance.new("IntValue")
    Cash.Parent = Stats
    Cash.Name = "Cash"
    Cash.Value = 0

end

game.Players.ChildAdded:connect(CreateStats)

When I test the game the leaderboard doesn't show up, but I don't know why. I would thank if someone could help me.

- mranderson11

2 answers

Log in to vote
1
Answered by
TofuBytes 500 Moderation Voter
10 years ago

This should work. You start off with 0 anyways, so there's no reason to include it. Hopefully this helps! :)

game.Players.PlayerAdded:connect(function(player)
    local ls = Instance.new("IntValue",player)
    ls.Name = "leaderstats"
    local points = Instance.new("IntValue",ls)
    points.Name = "Cash"
end)

Make sure you accept an answer, so we don't have to come back to answered questions.

Ad
Log in to vote
0
Answered by
HexC3D 830 Moderation Voter
10 years ago

Mistake1 there is supposed to be model inside player first then make intvalue inside model.



game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("Model", player) leaderstats.Name = "leaderstats" Instance.new("IntValue", leaderstats).Name = "Cash" end)

If this helped +1

Answer this question