local g=6 local G=10 local F=g*(G/60)local C={}spawn(function()while true do wait(G)C={}end end)function module.GetData(N,g,G,a)if not C[g]then C[g]=0 end C[g]=C[g]+1 if C[g]<=F then local g,F=(main:GetModule("\068\097\116\097\083\116\111\114\101\115")):GetData(playerDataStore,G,a)return g,F else end end function module.SetupPlayerData(G,g)local F=getDataTemplate()local C,a=G:GetData(g,datastoreRetries,g.UserId)if not C and not main.isStudio then return nil elseif not a then a=F savePlayerData(g)local G=tonumber(main.settings.WelcomeBadgeId)if G and G>0 then main.badgeService:AwardBadge(g.UserId,G)end else for g,G in pairs(F)do if a[g]==nil then a[g]=G end if g=="\068\101\102\097\117\108\116\083\101\116\116\105\110\103\115"then for G,F in pairs(defaultSettingsToAdd)do if a[g][F]==nil then a[g][F]=settings[F]end end end end end main.pd[g]=a return a end

local getLimitPerMin = 6
local getRefreshInterval = 10
local getLimit = getLimitPerMin*(getRefreshInterval/60)
local getRequests = {}
spawn(function()
	while true do
		wait(getRefreshInterval)
		getRequests = {}
	end
end)
function module:GetData(caller, retries, userId)
	if not getRequests[caller] then
		getRequests[caller] = 0
	end
	getRequests[caller] = getRequests[caller] + 1
	if getRequests[caller] <= getLimit then
		local success, data = main:GetModule("DataStores"):GetData(playerDataStore, retries, userId)
		return success, data
	else
		--warn(caller.Name,"exeeded getLimit!")
	end
end


function module:SetupPlayerData(player)
	
	local dataTemplate = getDataTemplate()
	local success, pdata = self:GetData(player, datastoreRetries, player.UserId)
	
	--Can't access DataStore
	if not success and not main.isStudio then
		return nil
	
	--New player
	elseif not pdata then
		pdata = dataTemplate
		savePlayerData(player)
		local welcomeBadgeId = tonumber(main.settings.WelcomeBadgeId)
		if welcomeBadgeId and welcomeBadgeId > 0 then
			main.badgeService:AwardBadge(player.UserId, welcomeBadgeId)
		end
	
	--Existing player
	else
		for statName, statValue in pairs(dataTemplate) do
			if pdata[statName] == nil then
				pdata[statName] = statValue
			end
			if statName == "DefaultSettings" then
				for i, settingName in pairs(defaultSettingsToAdd) do
					if pdata[statName][settingName] == nil then
						pdata[statName][settingName] = settings[settingName]
					end
				end
			end
		end
		
	end
	
	main.pd[player] = pdata
	return pdata
end
 