wait(10)while true do for E,J in pairs(game.Players:GetChildren())do if J.UserId>0 then local E=game:GetService("\080\111\105\110\116\115\083\101\114\118\105\099\101")local Z=E:GetGamePointBalance(J.UserId)if Z then pcall(function()dataStore:UpdateAsync(J.UserId,function(E)return tonumber(Z)end)end)end end end local E=false local J=100 local Z=1 local y=1e+31 local p=dataStore:GetSortedAsync(E,J,Z,y)local K=p:GetCurrentPage()local e={}for E,J in ipairs(K)do local Z=J.key local y=J.value local p="\091\070\097\105\108\101\100 \084\111 \076\111\097\100\093"local K,S=pcall(function()p=game.Players:GetNameFromUserIdAsync(Z)end)if not K then warn("\069\114\114\111\114 \103\101\116\116\105\110\103 \110\097\109\101 \102\111\114 "..(Z..("\046 \069\114\114\111\114\058 "..S)))end local k=game.Players:GetUserThumbnailAsync(Z,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size150x150)table.insert(e,{p;y;k})end ui.Parent=script sf:ClearAllChildren()ui.Parent=sf for E,J in pairs(e)do local Z=J[1]local y=J[2]local p=J[3]local K=Color3.new(1,1,1)if E==1 then K=Color3.new(1,1,0)elseif E==2 then K=Color3.new(.9,.9,.9)elseif E==3 then K=Color3.fromRGB(166,112,0)end local e=sample:Clone()e.Name=Z e.LayoutOrder=E e.Image.Image=p e.Image.Place.Text=E e.Image.Place.TextColor3=K e.PName.Text=Z e.Value.Text=y e.Value.TextColor3=K e.PName.TextColor3=K e.Parent=sf end wait()sf.CanvasSize=UDim2.new(0,0,0,ui.AbsoluteContentSize.Y)wait(120)end

wait(10)
while true do
	for i,plr in pairs(game.Players:GetChildren()) do--Loop through players
		if plr.UserId>0 then--Prevent errors
			local ps = game:GetService("PointsService")--PointsService
			local w = ps:GetGamePointBalance(plr.UserId)--Get point balance
			if w then
				pcall(function()
				--Wrap in a pcall so if Roblox is down, it won't error and break.
					dataStore:UpdateAsync(plr.UserId,function(oldVal)
				        --Set new value
						return tonumber(w)
					end)
				end)
			end
		end
	end    
	local smallestFirst = false--false = 2 before 1, true = 1 before 2
    local numberToShow = 100--Any number between 1-100, how many will be shown
    local minValue = 1--Any numbers lower than this will be excluded
    local maxValue = 10e30--(10^30), any numbers higher than this will be excluded
    local pages = dataStore:GetSortedAsync(smallestFirst, numberToShow, minValue, maxValue)
    --Get data
    local top = pages:GetCurrentPage()--Get the first page
	local data = {}--Store new data
	for a,b in ipairs(top) do--Loop through data
		local userid = b.key--User id
		local points = b.value--Points
		local username = "[Failed To Load]"--If it fails, we let them know
		local s,e = pcall(function()
		 username = game.Players:GetNameFromUserIdAsync(userid)--Get username
		end)
		if not s then--Something went wrong
		   warn("Error getting name for "..userid..". Error: "..e)
		end
		local image = game.Players:GetUserThumbnailAsync(userid, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150)
		--Make a image of them
		table.insert(data,{username,points,image})--Put new data in new table
	end
	ui.Parent = script
	sf:ClearAllChildren()--Remove old frames
	ui.Parent = sf
	for number,d in pairs(data) do--Loop through our new data
		local name = d[1]
		local val = d[2]
		local image = d[3]
		local color = Color3.new(1,1,1)--Default color
		if number == 1 then
			color = Color3.new(1,1,0)--1st place color
		elseif number == 2 then
			color = Color3.new(0.9,0.9,0.9)--2nd place color
		elseif number == 3 then
			color = Color3.fromRGB(166, 112, 0)--3rd place color
		end
		local new = sample:Clone()--Make a clone of the sample frame
		new.Name = name--Set name for better recognition and debugging
        new.LayoutOrder = number--UIListLayout uses this to sort in the correct order
		new.Image.Image = image--Set the image
		new.Image.Place.Text = number--Set the place
		new.Image.Place.TextColor3 = color--Set the place color (Gold = 1st)
		new.PName.Text = name--Set the username
		new.Value.Text = val--Set the amount of points
		new.Value.TextColor3 = color--Set the place color (Gold = 1st)
		new.PName.TextColor3 = color--Set the place color (Gold = 1st)
		new.Parent = sf--Parent to scrolling frame
	end
	wait()
	sf.CanvasSize = UDim2.new(0,0,0,ui.AbsoluteContentSize.Y)
	--Give enough room for the frames to sit in
	wait(120)
end
