Custom leaderboard not working with scrollingframe

I made a custom leaderboard, but for some reason when I try to use a scrolling frame for the playerlist, instead of a frame, it messes up.
When I use a scrollbar:

When I use a frame:
image

local players = game:GetService("Players")
local playerFrame = game.ReplicatedStorage.PlayerFrame
local List = script.Parent.ScrollingFrame
local position = UDim2.new({0.818, 0},{0.069, 0})

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
function  add()
	for i, v in pairs(List:GetChildren()) do
		v:Destroy()
end
	for i, v in pairs(players:GetChildren()) do
		local newFrame = playerFrame:Clone()
		newFrame.Parent = List
		local Name = newFrame:FindFirstChild("PlayerName")
		Name.Text = v.Name
		newFrame.Position = position
		position = position + UDim2.new(0, 0, 0.145, 0)

		
		
	end
	position = UDim2.new({0.818, 0},{0.069, 0})
end
players.ChildAdded:Connect(function()
		add()
end)

wait(0.5)
add()

	players.ChildRemoved:Connect(function()
		add()
end)```
![image|188x80](upload://1KQbFreO86LjYFrqVWt7rB8fyV9.png)

This is because you are using Scale instead of offset. In a ScrollingFrame, it will base the scale off of the AbsoulteSize instead of the Size. To combat this you could either use offset for positioning or adjust the scale to the ScrollingFrame size.

So should I change the size of the scrolling frame to offset & the players frame?

I mean change the size of your PlayerFrames and keep the ScrollingFrame.

Change the size of the playerFrames to offset instead of scale if Iā€™m not mistaken, right?

Correct!

This line of code right here it looks like

1 Like