local b=nil local E,p=pcall(function()b=(game:GetService("\068\097\116\097\083\116\111\114\101\083\101\114\118\105\099\101")):GetOrderedDataStore(TIME_PLAYED_DATA_STORE)end)if not E or b==nil then warn(p)script.Parent:Destroy()end module.TimePlayedResult=nil module.MostTipsResult=nil module.GetTimePlayedResult=function()return module.TimePlayedResult end module.GetTipsResult=function()return module.MostTipsResult end module.UpdateAsync=function()module.TimePlayedResult=(b:GetSortedAsync(false,10,1)):GetCurrentPage()end module.StartLoop=function()local E,p=coroutine.resume(coroutine.create(function()while wait(SCORE_UPDATE*57)do local E=(game:GetService("\080\108\097\121\101\114\115")):GetPlayers()for E,p in pairs(E)do local l=NAME_OF_STAT..p.UserId local m=b:IncrementAsync(l,SCORE_UPDATE)if DO_DEBUG then print("\073\110\099\114\101\109\101\110\116\101\100 \116\105\109\101 \112\108\097\121\101\100 \115\116\097\116 \111\102",p,l,"\116\111",m)end end module.UpdateAsync()end end))if not E then warn(p)end end return module
-- gets the datastore, fails if could not find
local TimePlayedDatabase = nil
local suc, err = pcall(function()
	TimePlayedDatabase = game:GetService("DataStoreService"):GetOrderedDataStore(TIME_PLAYED_DATA_STORE)
end)
if not suc or TimePlayedDatabase == nil then
	warn(err)
	script.Parent:Destroy()
end

module.TimePlayedResult = nil
module.MostTipsResult = nil

module.GetTimePlayedResult = function()
	return module.TimePlayedResult
end

module.GetTipsResult = function()
	return module.MostTipsResult
end

module.UpdateAsync = function()
	module.TimePlayedResult = TimePlayedDatabase:GetSortedAsync(false, 10, 1):GetCurrentPage()
end

module.StartLoop = function()
	local suc, err = coroutine.resume(coroutine.create(function()
		while wait(SCORE_UPDATE * (60 - 3)) do
			local players = game:GetService("Players"):GetPlayers()
			for _, player in pairs(players) do
				local stat = NAME_OF_STAT .. player.UserId
				local newval = TimePlayedDatabase:IncrementAsync(stat, SCORE_UPDATE)
				if DO_DEBUG then
					print("Incremented time played stat of", player, stat, "to", newval)
				end
			end
			module.UpdateAsync()
		end
	end))
	if not suc then
		warn(err)
	end
end
return module
