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

How do I make my leaderboard script more consistent? [IMAGE LINKS]

Images:

https://cdn.discordapp.com/attachments/340756143527690240/341030478696022016/RobloxScreenShot20170729_193202268.png

https://cdn.discordapp.com/attachments/340756143527690240/341026727868235786/image.png

The script is supposed to have a leaderboard with one value for group rank and one for role in game which for the time being should just reset to say "nothing".

The value for Team Role often is just labeled as "Value" and sometimes duplicated.

(the version of the script I am posting is just one try i've attempted other variations)

game.Players.PlayerAdded:connect(function(plr)
	wait()
	local lead = Instance.new('Model', plr)
	lead.Name = "leaderstats"
	
	local rank = Instance.new('StringValue', lead)
	rank.Name = "Group Rank"
	wait()
	rank.Value = plr:GetRoleInGroup(3324634)
	
	local role = Instance.new('StringValue', lead)
	wait()
	if lead:FindFirstChild('Value') then
		lead.Value.Name = "Team Role"
		lead.Value.Value = "nothing"
	end
end)

2 comments

0

The image links are actually unavailable

0

broken * the links are broke*

1 answer

Problem:

I have found various problems in your script. Second, don't use the extra part for Instance.new() for the parent portion. Manually set it like I did below as it is more efficient. Third, you are using :GetRoleInGroup() for the rank. The role is a integer not a string. Fourth, I added the extra part for the :GetRoleInGroup() . Lastly, I highly recommend using a Folder instead of a model as it is more convenient and safer.

Solution:

I fixed up your parenting, instances, and value system. Etc.

Code:

local group = 000000 --Insert the id for your group

game.Players.PlayerAdded:Connect(function(plr) --connect is deprecated use Connect
	local lead = Instance.new("Folder") --Recommended to use a Folder and to not use the extra , for the parent. Set it like this. It is more efficent
	lead.Parent = plr
	lead.Name = "leaderstats"

	local rank = Instance.new("IntValue") --This is suppose to be rank so use :GetRankInGroup() so then use a Integer
	rank.Parent = lead
	rank.Name = "Group Rank"
	rank.Value = plr:GetRankInGroup(group)

	local role = Instance.new("StringValue")
	role.Parent = lead
	role.Name = "Group Role" --I assume that is what you want to name it
	role.Value = plr:GetRoleInGroup(group)
	if lead:FindFirstChild('Value') then
		lead.Value.Name = "Team Role"
		lead.Value.Value = "nothing"
end
end)

If you have any questions don't forget to comment I would be glad to answer. If this helped you don't forget to accept my answer.

2 comments

0

connect is deprecated??

0

Yes, Connect is now in replacement for it @creeperhunter76

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