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

Is there anything wrong with this Group Leaderboard?

Asked by 8 years ago
Edited 8 years ago

I made a custom leaderboard, yet it will not work, it says I have no errors, please help

01game.Players.PlayerAdded:connect(function(plr)
02 
03local stats =game.Players.LocalPlayer.Instance.new("IntValue", plr)
04 
05    stats.Name = 'leaderstats'
06    stats.Value = 0
07local Rank = game.Instance.new("StringValue", stats)
08 
09    Rank.name = 'NYP Rank'
10    Rank.Value = plr:GetRoleInGroup(2841538)
11 
12 
13stats.Parent = plr
14Rank.Parent = stats
15 
16end)

Thanks, and happy thanksgiving o3o -Rich

0
Fix your formatting. Put the ~ on a new line for it to work. TheDeadlyPanther 2460 — 8y
0
Sorry, mb, gg MrRichGuy0210 17 — 8y
0
Why is this a local script? User#5423 17 — 8y
0
It's not a local script. MrRichGuy0210 17 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

Here is some fixed code, with explanations:

01game.Players.PlayerAdded:connect(function(p)
02    local stats = Instance.new("Folder") -- Folder because it is better for organization
03    stats.Parent = p
04    stats.Name = "leaderstats" -- I missed this, but it is required to be named leaderstats for it to show up
05 
06    local rank = Instance.new("StringValue") -- Using the second parameter is less efficient
07    rank.Parent = p
08    rank.Name = "NYP Rank" -- Lua is case-sensitive
09    rank.Value = p:GetRoleInGroup(2841538)
10 
11    -- There is no need to set the parents again
12end)

Hope I helped!

~TDP

0
It still didn't work.. I think my game just sucks, xD MrRichGuy0210 17 — 8y
0
Ah, I missed one big thing. Let me edit. Remember in Lua, anything that doesn't work, doesn't work for a reason. TheDeadlyPanther 2460 — 8y
0
Nvm, I just rescripted it and I saw the error I made, gg, thanks! MrRichGuy0210 17 — 8y
Ad

Answer this question