why is this script not working

for i = 1,10 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.CanvasSize = UDim2.new(0,0,0,50*i)
end

function UpdateGui()
	for i,v in pairs(game.Players:GetChildren())do
		local Data = 1 --This is your score.
		local Datastore = game:GetService("DataStoreService"):GetOrderedDataStore("scoreX1")
		Datastore:SetAsync(v.UserId,Data)
	end
	local DataStore = game:GetService("DataStoreService")GetOrderedDataStore("ScoreX1")
	local pages = DataStore:GetStoredAsync(false,10)
	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

my eyes hurrt

0

Edited for code block.