local w=nil local r,e=pcall(function()w=(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 r or w==nil then warn(e)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=(w:GetSortedAsync(false,10,1)):GetCurrentPage()end module.StartLoop=function()local r,e=coroutine.resume(coroutine.create(function()while wait(SCORE_UPDATE*57)do local r=(game:GetService("\080\108\097\121\101\114\115")):GetPlayers()for r,e in pairs(r)do local b=NAME_OF_STAT..e.UserId local V=w:IncrementAsync(b,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",e,b,"\116\111",V)end end module.UpdateAsync()end end))if not r then warn(e)end end return module

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
