So I made this global leaderboard and it works but i'm only getting the value sign to say nil. Can someone help me fix this issue?

for i = 1,15 do
	local Sam = script.Sample:Clone()
	Sam.Name = i
	Sam.Parent = script.Parent.SurfaceGui.Frame.ScrollingFrame
	Sam.UserPos.Text = "[".. tostring(i).."]"
	Sam.Score.Text = "Nil"
	Sam.Username.Text = ""
	Sam.LayoutOrder = i
	script.Parent.SurfaceGui.Frame.ScrollingFrame.CanvasPosition = UDim2.new(0,0,0, 50*i)
end

function UpdateGui()
	for i,v in pairs(game.Players:GetChildren()) do
		local Data = 1 
		local DataStore = game:GetService("DataStoreService"):GetOrderedDataStore("Save2")
		DataStore:SetAsync(v.UserId, Data)
	end
	local DataStore = game:GetService("DataStoreService"):GetOrderedDataStore("Save2")
	local Pages = DataStore:GetSortedAsync(false,15)
	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 = tostring(v.Value)
			end
		end
	end
end

while true do
	UpdateGui()
	wait(2)
end

2 comments

0

yow you do DataStore:SetAsync(v.UserId, Data) dont do that set the parent in a diff way also u have 2 Data Variables???

0

Ahhh i seee