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

Having trouble with the extending the Leaderboard to show 2 group ranks and kills&deaths?

Hi there, I would like to know how to extend the leaderboard that shows kills and deaths and also 2 groups? something like the army groups where they have divisions and suchthat show the players division, rank in the main group and division group and also their kills and deaths, I've managed to get 1 group to show on the leaderboard, but can't find out how to extend it to show another group and kills and deaths.

2 comments

0

You'll need to make your own leaderboard for that.

0

How I do that?

1 answer

✓ Accepted answer

A leaderboard can be formed by making a folder/model called leaderstats, as a child of a player. We can connect to the player by using the PlayerAdded Method. We will then create a new folder, called leaderstats, and add the necesery values.

First, we need to connect to the player.

game.Players.PlayerAdded:Connect(function(plr)
	-- we will continue the code here
end)

Now that we have connected to a player that just joined, we will want to make the leaderstats folder.

local leaderstats = Instance.new("Folder") -- creates the folder
leaderstats.Parent = plr -- places it as a child of the player
leaderstats.Name = "leaderstats" -- names the folder

Now that we have the leaderstats folder, we will need the values. Let's begin with the deaths!

local deaths = Instance.new("IntValue") -- creates the integer value
deaths.Parent = leaderstats -- places it as a child of leaderstats
deaths.Name = "Deaths" -- names the value
if plr.Character then -- if the player has a character
	plr.Character.Humanoid.Died:Connect(function() -- if the character died
		deaths.Value = deaths.Value+1 -- adds 1 more death to the value
	end
end

Now that we have the Deaths value, let's get into the kills value! Unfortunately, the kills value will only work if there is a remote event, and I will not be covering that.

local kills = Instance.new("IntValue") -- creates the value
kills.Parent = leaderstats -- places the value as a child of leaderstats
kills.Name = "Kills" -- names the value

Now that we have the Deaths and the kills values, let's move onto the group roles! Let's start with Group1

local group1 = Instance.new("IntValue") -- creates the value for group1
group1.Name = "Group1" -- CHANGE "Group1" TO YOUR GROUP NAME
group1.Parent = leaderstats
group1.Value = plr:GetRoleInGruop(Group1) -- CHANGE "Group1" TO YOUR GROUP ID

Not let's move onto Group2

local group2 = Instance.new("IntValue") -- creates the value for group1
group2.Name = "Group2" -- CHANGE "Group2" TO YOUR GROUP NAME
group2.Parent = leaderstats
group2.Value = plr:GetRoleInGroup(Group2) -- CHANGE "Group2" TO YOUR GROUP ID

That's it, we are done!

Here's our finished work!

game.Players.PlayerAdded:Connect(function(plr)
	-- leaderstats
	local leaderstats = Instance.new("Folder") -- creates the folder
	leaderstats.Parent = plr -- places it as a child of the player
	leaderstats.Name = "leaderstats" -- names the folder	
	
	--Deaths
	local deaths = Instance.new("IntValue") -- creates the integer value
	deaths.Parent = leaderstats -- places it as a child of leaderstats
	deaths.Name = "Deaths" -- names the value
	if plr.Character then -- if the player has a character
		plr.Character.Humanoid.Died:Connect(function() -- if the character died
			deaths.Value = deaths.Value+1 -- adds 1 more death to the value
		end
	end
	
	--Group1
	local group1 = Instance.new("IntValue") -- creates the value for group1
	group1.Name = "Group1" -- CHANGE "Group1" TO YOUR GROUP NAME
	group1.Parent = leaderstats
	group1.Value = plr:GetRoleInGroup(Group1) -- CHANGE "Group1" TO YOUR GROUP ID
	
	--Group2
	local group2 = Instance.new("IntValue") -- creates the value for group1
group2.Name = "Group2" -- CHANGE "Group2" TO YOUR GROUP NAME
group2.Parent = leaderstats
group2.Value = plr:GetRoleInGroup(Group2) -- CHANGE "Group2" TO YOUR GROUP ID

end)

5 comments

0

Thanks for this, but a small problem came up, it's working but under the groups there is numbers and not the rank have I missreplaced something?

0

Ok, I will fix it!

0

It's done! Accept the answer if you are pleased!

0

Sorry for the late reply, urm I don't know what went wrong but now it not working... I don't know why the coding is all right, any thoughts why?

0

Idk

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