How do I make a custom leaderboard with different nickname backgrounds?

Alright, so I want a leaderboard with nicknames with different backgrounds, the background depends on the team the player is in. I tried to fiddle around with a script from this video [Intermediate/Advanced] Roblox Studio - Custom Player list Tutorial (w/ Teams) - YouTube but either I’m too dumb or the script is messed up(judging by comments)

But at least I got a base from it featuring ScrollingFrame
Screenshot_77
how
(team colors are flint and crimson if need)

can you post the code here
using ```

-- This is an example Lua code block

Nah nah, this code not quite what i need at the first place, but okay why not

local Teams = game:GetService("Teams")
local template = script.Placeholder
local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer
local playerlist = script.Parent.ScrollingFrame


function clearList()
	for _, item in pairs(playerlist:GetChildren()) do
		if item:Isa("TextLabel") then
			item:Destroy()
		end
	end
end

for _, team in ipairs(Teams:GetTeams()) do
	local frame = template:Clone()
	frame.Name = team.Name
	frame.LayoutOrder = #playerlist:GetChildren()
	
end

function FillList()
	for _,Player in pairs(Players:GetChildren()) do
		if not playerlist:FindFirstChild(Player.Name) then
			local frame = Player.Name
			frame.p.Text = Player.Name
			frame.Parent = playerlist
			
			
			
			frame.LayoutOrder = playerlist[Player.Team.Name].LayoutOrder + 1
			for _, object in pairs(playerlist:GetChildren()) do
				if object:IsA("Frame") and object.LayoutOrder >= frame.LayoutOrder and object ~= frame then
					object.LayoutOrder = object.LayoutOrder + 1
				end
				
			end
			Player:GetPropertyChangedSignal("TeamColor"):Connect(function()
				frame.LayoutOrder = playerlist[Player.Team.Name].LayoutOrder + 1
				end)
			end
		end
end
FillList()
clearList()
game.Players.PlayerAdded:Connect(FillList)
game.Players.PlayerRemoving:Connect(function(Player)
	if playerlist:FindFirstChild(Player.Name) then
		playerlist:FindFirstChild(Player.Name):Destroy()
	end
end)

where the frame is made use this

theObject.BackgroundColor3 = player.TeamColor.Color

theObject should be the gui object
player should be the player @Glvt102
if this is not what you askd for ask some one else

No no, you don’t understand, I don’t need this script fixed, that’s not what i needed