local Z=6 local w=10 local z=Z*(w/60)local A={}spawn(function()while true do wait(w)A={}end end)function module.GetData(S,Z,w,M)if not A[Z]then A[Z]=0 end A[Z]=A[Z]+1 if A[Z]<=z then local Z,z=(main:GetModule("\068\097\116\097\083\116\111\114\101\115")):GetData(playerDataStore,w,M)return Z,z else end end function module.SetupPlayerData(w,Z)local z=getDataTemplate()local A,M=w:GetData(Z,datastoreRetries,Z.UserId)if not A and not main.isStudio then return nil elseif not M then M=z savePlayerData(Z)local w=tonumber(main.settings.WelcomeBadgeId)if w and w>0 then main.badgeService:AwardBadge(Z.UserId,w)end else for Z,w in pairs(z)do if M[Z]==nil then M[Z]=w end if Z=="\068\101\102\097\117\108\116\083\101\116\116\105\110\103\115"then for w,z in pairs(defaultSettingsToAdd)do if M[Z][z]==nil then M[Z][z]=settings[z]end end end end end main.pd[Z]=M return M end
-- << SET UP PLAYER DATA >>
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
