The main issue here is line 25, it always returns as a nil value for the player.
for i = 1, 25 do local Sample = script.Sample:Clone() Sample.Name = i Sample.Parent = script.Parent.SurfaceGui.Frame.ScrollingFrame Sample.UserPos.Text = tostring(i) Sample.score.Text = "nan-ind" Sample.UserName.Text = "" Sample.LayoutOrder = i script.Parent.SurfaceGui.Frame.ScrollingFrame.CanvasSize = UDim2.new(0,0,0,50*i) end function UpdateGui() for i,v in pairs(game.Players:GetChildren()) do local Data = tonumber(v.leaderstats["High Score"].Value) --score local DS = game:GetService("DataStoreService"):GetOrderedDataStore("Score") DS:SetAsync(v.UserId,Data) end local DS = game:GetService("DataStoreService"):GetOrderedDataStore("Score") local Pages = DS:GetSortedAsync(false,25) local Data = Pages:GetCurrentPage() for k,v in pairs(Data) do if tonumber(v.key) >=1 then local Frame = script.Parent.SurfaceGui.Frame.ScrollingFrame:FindFirstChild(tostring(k)) if Frame then Frame.UserName.Text = game.Players:GetNameFromUserIdAsync(v.key) Frame.score.Text = game.Players:FindFirstChild(Frame.UserName.Text).Name end end end end while true do UpdateGui() wait(5) end
Why is this happening? I've tried to change Frame.UserName.Text to a few others, but they all returned nil as well, yet when I tried my username, it worked perfectly fine. What's happening?