Can someone explain me how this script doesn’t delete the content inside the scrolling frame? bc it doubles all the time-
local function InsertTemplateFrame()
for _, leaderboard in pairs(leaderboards) do
local scrollingFrame = leaderboard.Leaderboard.LeaderboardGui.LeaderboardContainer.PlayersContainer
if templateFrame.RankText.Text == "1" then
for __, child in pairs(scrollingFrame:GetChildren()) do
if child.ClassName == templateFrame.ClassName then
child:Destroy() --// This part is what I need help with bc it doesn't destroy nor update globally, it only updates for 1 person and the rest glitches.
end
end
end
local newPlayerFrame = templateFrame:Clone()
newPlayerFrame.Parent = scrollingFrame
if scrollingFrame.AbsoluteWindowSize.Y >= scrollingFrame.AbsoluteCanvasSize.Y then
scrollingFrame.ScrollingEnabled = false
else
scrollingFrame.ScrollingEnabled = true
end
local plr = game.Players:FindFirstChild(templateFrame.NameText.Text)
if plr then
local plrTimeValue = Leaderstats.GetTime(plr)
newPlayerFrame.TimeText.Text = plrTimeValue.Value
local connection = nil
connection = plrTimeValue:GetPropertyChangedSignal("Value"):Connect(function()
newPlayerFrame.TimeText.Text = plrTimeValue.Value
end)
newPlayerFrame.Destroying:Connect(function()
connection:Disconnect()
end)
end
end
end