Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there anything wrong with this Group Leaderboard?

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



game.Players.PlayerAdded:connect(function(plr)
	
local stats =game.Players.LocalPlayer.Instance.new("IntValue", plr)
	
	stats.Name = 'leaderstats'
	stats.Value = 0
local Rank = game.Instance.new("StringValue", stats)

	Rank.name = 'NYP Rank'
	Rank.Value = plr:GetRoleInGroup(2841538)
	
	
stats.Parent = plr
Rank.Parent = stats

end)

Thanks, and happy thanksgiving o3o -Rich

4 comments

0

Fix your formatting. Put the ~ on a new line for it to work.

0

Sorry, mb, gg

0

Why is this a local script?

0

It's not a local script.

1 answer

✓ Accepted answer

Here is some fixed code, with explanations:

game.Players.PlayerAdded:connect(function(p)
	local stats = Instance.new("Folder") -- Folder because it is better for organization
	stats.Parent = p
	stats.Name = "leaderstats" -- I missed this, but it is required to be named leaderstats for it to show up
	
	local rank = Instance.new("StringValue") -- Using the second parameter is less efficient
	rank.Parent = p
	rank.Name = "NYP Rank" -- Lua is case-sensitive
	rank.Value = p:GetRoleInGroup(2841538)

	-- There is no need to set the parents again
end)

Hope I helped!

~TDP

3 comments

0

It still didn't work.. I think my game just sucks, xD

0

Ah, I missed one big thing. Let me edit. Remember in Lua, anything that doesn't work, doesn't work for a reason.

0

Nvm, I just rescripted it and I saw the error I made, gg, thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.