Surface GUI Scrolling Frame is spaced weirdly

Hi! So I made a leaderboard that shows the top people with the most wins. But when it displays the cloned frame for each player on the leaderboard, it is spaced out extremely far. It looks like this:
image
image
Heres my script:

local DataStore = game:GetService("DataStoreService")
local WinsLB = DataStore:GetOrderedDataStore("DonationLeaderboards")
local leaderboard = game.Workspace.Leaderboard

local function updateLeaderboards()

	local success, errorMessage = pcall(function()

		local Data = WinsLB:GetSortedAsync(false, 50)
		local Winspage = Data:GetCurrentPage()

		print("set leaderboard frame")
		
		for rank, data in ipairs(Winspage) do
			
			local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
			local userId = game.Players:GetUserIdFromNameAsync(userName)
			local Wins = data.value
			local isOnLeaderboard = false
			
			for i, v in pairs(leaderboard.RealLeaderboard.SurfaceGui.Holder:GetChildren()) do
				if v:IsA("Frame") then
					if v.Player.Text == userName then
						break
					end
				end

			end


			if Wins and isOnLeaderboard == false then
				local NewLBFrame = game.ReplicatedStorage:WaitForChild("LeaderboardFrame"):Clone()
				local statLabel = NewLBFrame.Stat
				
				NewLBFrame.Player.Text = userName
				NewLBFrame.Player.avatar.Image = game.Players:GetUserThumbnailAsync(userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
				statLabel.Text = Wins
				NewLBFrame.Rank.Text = "#"..rank

				
				NewLBFrame.Parent = leaderboard.RealLeaderboard.SurfaceGui.Holder
				
				if rank == 1 then
					NewLBFrame.Player.TextColor3 = Color3.new(1, 0.705882, 0.227451)
					statLabel.TextColor3 = Color3.new(1, 0.705882, 0.227451)
					NewLBFrame.Rank.TextColor3 = Color3.new(1, 0.705882, 0.227451)
					
				elseif rank == 2 then
					NewLBFrame.Player.TextColor3 = Color3.new(0.721294, 0.721279, 0.721279)
					statLabel.TextColor3 = Color3.new(0.721294, 0.721279, 0.721279)
					NewLBFrame.Rank.TextColor3 = Color3.new(0.721294, 0.721279, 0.721279)
					
				elseif rank == 3 then
					NewLBFrame.Player.TextColor3 = Color3.new(0.736507, 0.487678, 0.259174)
					statLabel.TextColor3 = Color3.new(0.736507, 0.487678, 0.259174)
					NewLBFrame.Rank.TextColor3 = Color3.new(0.736507, 0.487678, 0.259174)
					
				end 
			end
		end
	end)
	
	if not success then
		print(errorMessage)
	end

end

while true do

	for _, player in pairs(game.Players:GetPlayers()) do
		local stat = player.leaderstats.Wins
		
		WinsLB:SetAsync(player.UserId, stat.Value)
	end
	
	for _, frame in pairs(leaderboard.RealLeaderboard.SurfaceGui.Holder:GetChildren()) do
		if frame:IsA("Frame") then
			frame:Destroy()
		end
	end

	updateLeaderboards()
	wait(10)

end

I have a UIListLayout inside the scrolling frame with these settings:
image

I believe it has to do with the UIListLayout because when I get rid of it, all the cloned frames are on top of each other. Can you help me?

1 Like

Make sure the size of the cloned Leaderboard frame isn’t super large. Its most likely beacuse the frame containing all the stats for the player scaled improperly.

Leaderboard frame needs to be pixels instead of scale i think

Can you elaborate what you mean by that?

image
Do you have scale instead of offset? if so then use offset for the Y value as offset uses pixels instead of scale because scale uses the percentage of the scrolling frame.

Udim2.new(1, 0, 0, 50) This size would be 50 pixels down on the Y-axis and 100% on the X-axis.

It always helps to have UIListLayout in your leaderboard, as well as UIAspectRatioConstraint.

Please read the post before commenting.

The problem with this is the size of my cloned frame is .1 but the lowest I can make offset is 1. What would I do here?

put the player frame size to {1, 0},{0, 200} see if that works
offset is the amount of pixels so by settings offset to 1 you are basically just trying to set it to 1 pixel try 200 instead with 0 scale

Here is an example
Leaderboard.rbxm (11.1 KB)