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?

7 comments
do GetPlayers()
but where?
is it an issue with case? ie you're typing lowercase letters in the textbox, but the players name has a capital in it
No.
try enclosing the 'v.key' inside a tonumber(v.key) on line 25
Is Frame.score.Text nil?
So all i can think of is you are trying to find a player not in the game or something is wrong with how you are trying to get the players name so couldn''t you just set Frame.score.Text = Frame.UserName.Text?