This is the LocalScript

xpChanger.OnClientEvent:Connect(function(xpGiven)
	-- Save xp
	local curXp,curLvl = saveReturn:InvokeServer(xpGiven)
	-- Math
	local percentage = curXp/(10*curXp)
	local newXOffset = percentage*xOffsetXp
	-- Apply
	xpDisplay:TweenSize(UDim2.new(xScaleXp,newXOffset,xScaleXp,xOffsetXp),'Out','Quad',.5,false,nil)
	lvl.Text = 'Lvl: '..tostring(curLvl)
	xp.Text = 'Xp: '..tostring(curXp)
end)

This is the Script

local bool,message = pcall(function()
	saveReturn.OnServerInvoke = function(plr,xpGiven)
		local key = 'Player-'..plr.userId
		local curLvl = lvlDataStore:GetAsync(key)
		local lvlEquation = 10*curLvl
		-- Adds lvls and sets xp
		if curLvl == 0 and xpGiven == 10 then
			xpDataStore:SetAsync(key,(xpGiven - lvlEquation))
			lvlDataStore:SetAsync(key,(curLvl+1))
			print(curLvl+1)
			return xpDataStore:GetAsync(key),lvlDataStore:GetAsync(key)
		elseif lvlEquation == xpGiven then
			xpDataStore:SetAsync(key,(xpGiven - lvlEquation))
			lvlDataStore:SetAsync(key,(curLvl+1))
			print(curLvl+1)
			return xpDataStore:GetAsync(key),lvlDataStore:GetAsync(key)
		elseif curLvl == maxLvl then
			xpDataStore:SetAsync(key,(0))
			return xpDataStore:GetAsync(key),lvlDataStore:GetAsync(key)
		else
			xpDataStore:SetAsync(key,(xpGiven))
			return xpDataStore:GetAsync(key),lvlDataStore:GetAsync(key)
		end
	end
end)

3 comments

0

Look at how many times you're sending requests. There should be a 6 second cool down between requests

0

I made it immediately

0

It says "Try Sending Fewer Requests." sooooooo you need to Try Sending Fewer Requests. http://robloxdev.com/articles/Data-store limitations are shown on this page