How to refresh a custom leaderboard to show the newest players who have joined?

I have a custom leaderboard script, however, I am struggling to find out a way to rectify this issue. I have tried to disable and reenable the leaderboard upon a new player’s join, and this did not fix the problem. I also wish to maintain the icon functionality of this custom leaderboard, as this is the main reason why I’m looking to create a custom leaderboard…

localscript

game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)

local plr = game.Players.LocalPlayer
local Teams = game:GetService("Teams")
local replicatedStorage = game:GetService("ReplicatedStorage")
local ManagementEvent = replicatedStorage.ManagementTeam

local teamCheck = plr.Team

plr:GetPropertyChangedSignal("Team"):Connect(function()
	if plr.Team == Teams.Management then
		teamCheck = Teams.Management
		ManagementEvent:FireServer("test", teamCheck)
	end
end)

Serverscript

--Custom Leaderboard Script. Made by Leaderboard+ plugin (by Infinite_Visions).
--Find the plugin Documentation here: https://devforum.roblox.com/t/leaderboard-create-custom-leaderboards-in-studio/1338477

local Settings = script.Parent.Settings
local Path = nil
local Teams = game:GetService("Teams")
local replicatedStorage = game:GetService("ReplicatedStorage")
local managementEvent = replicatedStorage.ManagementTeam
local refreshEvent = replicatedStorage.RefreshEvent

--Handle Admins. If You Have no admins, ignore this.
local Admins = {
	"Infinite_Visions",
	"Example_Name_Here"
}

--Get Creator Id
local ownerId = nil
if game.CreatorType == Enum.CreatorType.Group then
	local PlaceInfo = game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId)
	ownerId = game:GetService("GroupService"):GetGroupInfoAsync(PlaceInfo.Creator.CreatorTargetId).Owner.Id
else
	ownerId = game.CreatorId
end

--Setup Players Already In-Game
for i, player in pairs(game.Players:GetChildren()) do
	--Add a slot to the leaderboard
	local NewSlot = script.Parent.LeaderboardFrame.HoldingFrame.Sample:Clone()
	NewSlot.Name = player.Name
	
	--Handle Names
	local NameText = nil
	
	if Settings.DisplayNames.Value == true then
		NameText = player.DisplayName
	else
		NameText = player.Name
	end
	
	if Settings.UpperCase.Value == true then
		NewSlot.PlrName.Text = string.upper(NameText)
	else
		NewSlot.PlrName.Text = NameText
	end
	
	--Handle Icons
	if player.UserId == ownerId and Settings.ShowOwner.Value == true then
		NewSlot.Owner.Visible = true
	else
		if Settings.ShowAdmin.Value == true then
			for i = 1, #Admins do
				if player.Name == Admins[i] then
					NewSlot.Admin.Visible = true
				end
			end
		elseif game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,13376596) and Settings.CustomGamepass.Value == true then	
			NewSlot.GamepassSymbol.Visible = true
		elseif player.MembershipType == Enum.MembershipType.Premium and Settings.ShowPremium.Value == true then
			NewSlot.Premium.Visible = true
		end
	end
	
	--If CustomData, Handle DataChanges
	if Settings.CustomData.Value == true then
		Path = script.Parent.Settings.CustomData		
		Path.Changed:Connect(function()
			NewSlot.Currency1.Text = Path.Value
		end)
	end
	NewSlot.Visible = true
	--The Path to the Values you want displayed, if any.
	NewSlot.Parent = script.Parent.LeaderboardFrame.HoldingFrame
end

game.Players.PlayerAdded:Connect(function(player)
	--Add a slot to the leaderboard
	local NewSlot = script.Parent.LeaderboardFrame.HoldingFrame.Sample:Clone()
	NewSlot.Name = player.Name
	
	--Handle Names
	local NameText = nil
	
	if Settings.DisplayNames.Value == true then
		NameText = player.DisplayName
	else
		NameText = player.Name
	end
	
	if Settings.UpperCase.Value == true then
		NewSlot.PlrName.Text = string.upper(NameText)
	else
		NewSlot.PlrName.Text = NameText
	end
	
	--Handle Icons
	if player.UserId == ownerId and Settings.ShowOwner.Value == true then
		NewSlot.Owner.Visible = true
	else
		if Settings.ShowAdmin.Value == true then
			for i = 1, #Admins do
				if player.Name == Admins[i] then
					NewSlot.Admin.Visible = true
				end
			end
		elseif game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,13376596) and Settings.CustomGamepass.Value == true then	
			NewSlot.GamepassSymbol.Visible = true
		elseif player.MembershipType == Enum.MembershipType.Premium and Settings.ShowPremium.Value == true then
			NewSlot.Premium.Visible = true
		end
	end
	
	--If CustomData, Handle DataChanges
	if Settings.CustomData.Value == true then
		Path = script.Parent.Settings.CustomData		
		Path.Changed:Connect(function()
			NewSlot.Currency1.Text = Path.Value
		end)
	end
	NewSlot.Visible = true
	
	local function test(arg1, arg2)
		print("testing", arg1, arg2)
	end
		end)

local teamImageVisible = game.ReplicatedStorage.TeamImageVisible
managementEvent.OnServerEvent:Connect(function(player, teststring, teamCheck)
	if teamCheck == Teams.Management then
		print(teamCheck)
		local NewSlot = script.Parent.LeaderboardFrame.HoldingFrame.Sample:Clone()
		NewSlot.Name = player.Name
		teamImageVisible:FireAllClients()
	end
end)

Are there any errors? Also can you send a model for us to test, that would help alot.

there are no errors for this to show, unfortunately

1 Like

I’m able to see my friend within the leaderboard but

he doesn’t see me

1 Like

You aren’t accounting for players that have already joined. You can use a loop like
for _, player in game.Players:GetPlayers() do
– do cool stuff with player instance
do
to then generate already joined players.

1 Like

I am rather new to scripting, where would I put this? In a server script, or local?

Where do you generate player entries? you would just do it there.

i am truly stumped on what to do, probably because i’ve been working on figuring this out for the past 7 hours now

Just use

Players#PlayerAdded

and
Players#PlayerRemoving

to detect when a player joins or leaves.