I’m making a custom leaderboard for my game. Everything looks right, but the script doesn’t work. the example is the only thing on the leaderboard and it doesn’t even move when I change teams.
I want to fix it.
I made it from this video [Intermediate/Advanced] Roblox Studio - Custom Player list Tutorial (w/ Teams) - YouTube
here’s the code
local Teams = game:GetService("Teams")
local template = script.Example
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.Player.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)
and here’s a picture of the folds