UILIstLayout break inside a ScrollingFrame sometimes

I have a custom player list for mobile players but sometimes the player frame randomly stacks on top of one another.
I have provided the screenshots below

In Game Screenshot

GUI Layout Screenshot

GUI

UIListLayout properties
Properties

The code

The code is working fine.

local item=script:FindFirstChild('Template')
local holder=script.Parent:WaitForChild('Frame'):WaitForChild("ScrollingFrame")

local function add(player)
	local new=item:clone()
	new.name.Text=player.Name
	new.Name=player.Name
	-- image	
	local size = Enum.ThumbnailSize.Size420x420
	local typee = Enum.ThumbnailType.AvatarBust
	local icon = game.Players:GetUserThumbnailAsync(player.UserId,typee,size)
	new.Icon.Image = icon
	new.Visible=true
	if not new.name.TextFits then
		new.name.TextScaled=true
	end
	if player.TeamColor == BrickColor.new("Lime green") then
		new.name.TextColor3 = Color3.fromRGB(56, 165, 9)
	end
	if player.TeamColor == BrickColor.new("New Yeller") then
		new.name.TextColor3 = Color3.fromRGB(226, 226, 0)
	end	
	new.Parent=holder
end

for i,v in pairs(game.Players:GetPlayers())do
	add (v)
end

game.Players.PlayerAdded:connect(function(player)
	add(player)
end)

game.Players.PlayerRemoving:connect(function(player)
	local find = holder:FindFirstChild(player.Name)
    if find then
        find:Destroy()
        for i,v in pairs(holder:GetChildren()) do
			if v.Name=='LocalScript' then
			else
				v:Destroy()
			end			
		end
	 	for i,v in pairs(game.Players:GetPlayers()) do
	    	add (v)
	    end
    end
end)
while wait(1) do
	for i,v in pairs(holder:GetChildren())do
		if v:IsA("Frame") then
			local player = game.Players:FindFirstChild(v.name.Text)
			if player then			
				if player.TeamColor == BrickColor.new("Lime green") then
					v.name.TextColor3 = Color3.fromRGB(56, 165, 9)
				end
				if player.TeamColor == BrickColor.new("New Yeller") then
					 v.name.TextColor3 = Color3.fromRGB(226, 226, 0)
				end
			end
		end
	end
end

Has anyone experienced this before?

Thanks for reading.

This is maybe because you didn’t add padding to it, try adding it then try.

No, I tried adding padding before but it did not fix the problem unfortunately.

Edit: Found the cause of this bug, when a player leaves, I rebuilt the leaderboard that causes the Layout to break for some reason.
It was this lines of code that broke the layout.