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

Why is there no leader board appearing in studio and in server?[EDIT]

Asked by
Peeshavee 226 Moderation Voter
8 years ago
Edited 8 years ago

So, I'm currently learning about Leader boards. I've read so far the whole wiki page, but now that I did what their script says, nothing appears. Here's the script:

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model")
    leaderstats.Name = "Points"
    leaderstats.Parent = player

    local coin = Instance.new("IntValue")
    coin.Value = 0
    coin.Name = "Coins Collected"
    coin.Parent = leaderstats
end)

Any ideas as to why nothing is appearing? All help is appreciated!

[EDIT PART]

So I've noticed that ROBLOX's script work's fine:

game.Players.PlayerAdded:connect(function(player)
     local leaderstats = Instance.new("Model")
     leaderstats.Name = "leaderstats"
     leaderstats.Parent = player

     local money = Instance.new("IntValue")
     money.Name = "Money" 
     money.Value = 0 
     money.Parent = leaderstats
 end)

What's the difference between my script, and theirs?

0
Ahh ok, the reason why is because when naming the 'leaderstats' variable, it HAS to have the name of 'leaderstats'. FiredDusk 1466 — 8y

1 answer

Log in to vote
1
Answered by
FiredDusk 1466 Moderation Voter
8 years ago
Edited 8 years ago

First off, make sure the script is not disabled. Also, I would make sure you parent the 'Model' and 'CoinValue' to where it needs to be before you name it and change the values of it.

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model")
    leaderstats.Parent = player --I parented here
    leaderstats.Name = "leaderstats" --Here, you HAVE to name it leaderstats, not too sure why but you HAVE too ;PP

    local coin = Instance.new("IntValue")
    coin.Parent = leaderstats --I parented here
    coin.Value = 0
    coin.Name = "Coins Collected"
end)

Hope this helped.

0
I tried parenting it first, but that didn't work. Peeshavee 226 — 8y
0
I edited my script, this should work. I made a new comment on line 4. FiredDusk 1466 — 8y
0
Ok, thanks that worked. Peeshavee 226 — 8y
0
Np FiredDusk 1466 — 8y
Ad

Answer this question