I did something similar to this whilst making a custom leaderboard yesterday.
What i did was I inserted a local script into a scrollingframe with the uilistlayout within. Then, inside the localscript I inserted the “Sample” which is the Instance that will be cloned (aka the template). This may not be an effective method, but it works for me.
Then in the code you could try:
local list = script.Parent -- Scrolling frame
game.Players.ChildRemoved:Connect(function(player) -- if plr leaves the game, it removes from list
if list:FindFirstChild(player.Name) then
list[player.Name]:Destroy()
end
end)
while task.wait(.05) do
for _, player in pairs(game.Players:GetPlayers()) do
if not list:FindFirstChild(player.Name) then
local cloning = script.Sample:Clone()
cloning.Name = player.Name
cloning.PlrName.Text = player.Name
cloning.Visible = true
cloning.Parent = list
else
local plr = list[player.Name]
plr.Money.Text = player.leaderstats.Money.Value
end
end
end