Hi! So I am having a problem with this global leaderboard where the thumbnail size of the player will be incredibly stretched out. Here is part of the leaderboard 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
You can see it sets the thumbnail size here:
game.Players:GetUserThumbnailAsync(userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
But the thumbnail looks like this:
The Frames for the top leaderboard players are in a scrolling frame with these settings:
And there is a UIListLayout with these settings:
How can I fix the stretched thumbnail?
Thanks. I now have a new error but I don’t want to make a new post because I feel i’ll be warned. The issue now is that it is only allowing one frame to be on the leaderboard, it isn’t cloning a new frame for every person. Instead, it will just have the one frame on the leaderboard with only the player first in wins, not the top 50. Here is my entire 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.Position = UDim2.new(0, 0, NewLBFrame.Position.Y.Scale + (0.1 * #leaderboard.RealLeaderboard.SurfaceGui.Holder:GetChildren()), 0)
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)
NewLBFrame.Avatar.BackgroundColor3 = Color3.new(0.997803, 0.884443, 0.247959)
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)
NewLBFrame.Avatar.BackgroundColor3 = 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)
NewLBFrame.Avatar.BackgroundColor3 = Color3.new(0.736507, 0.487678, 0.259174)
end
end
end
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
Im sorry I am flooding you with issues but I fixed the one I said and now I have a new one. The issue now is that each individual frame is spaced out a ton, around the size of the scrolling frame if you didn’t scroll at all. How to I get it so each frame is not spaced out that far? I double checked and made sure that the frame being cloned for each player isn’t a giant size.
i believe it has to do with the UIListLayout because when I get rid of it, all the grames are stacked on top of each other.