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.
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)