My CurrentXP value doesn't change when add 5!

So I have a problem with my ServerScript. Basically I want to value to go up by 5 every 3 second, but when the value is 5, it keep printing 5 and it got stuck.

What I want to achieve:

I want the value to add by 5 then multiply the Multiplier Value every 3 second

Profile Template Module:

local DataTemplate = {
	PlayerXPMultiplier = 1,
	PlayerRequireXP = 20,
	PlayerCurrentXP = 0,
	PlayerLevels  = 1,
	PlayerCash = 0,
	PlayerRebirths = 0
}



return DataTemplate

Server Script:

local function SetPlayerLevel(player: Player, enable: boolean)
	
	if enable == true then
		while task.wait(3) do
			local PlayerProfile = ProfileManager.Profiles[player]

			if not PlayerProfile then 
				return
			end

			local RequireXPData = PlayerProfile.Data.PlayerRequireXP
			local CurrentXPData = PlayerProfile.Data.PlayerCurrentXP
			local XPMultiplierData = PlayerProfile.Data.PlayerXPMultiplier
			local LevelsData = PlayerProfile.Data.PlayerLevels
			local RebirthsData = PlayerProfile.Data.PlayerRebirths
			local CashData = PlayerProfile.Data.PlayerCash

			local PlayerRequireXP = player:WaitForChild('PlayerRequireXP')
			local PlayerCurrentXP = player:WaitForChild('PlayerCurrentXP')
			local PlayerXPMultiplier = player:WaitForChild('PlayerXPMultiplier')
			local PlayerLevels = player:WaitForChild('PlayerLevels')
			local PlayerRebirths = player:WaitForChild('PlayerRebirths')
			local PlayerCash = player:WaitForChild('PlayerCash')
			
			CurrentXPData += 5 * XPMultiplierData
			PlayerCurrentXP.Value = CurrentXPData
			print(PlayerCurrentXP, CurrentXPData, XPMultiplierData)
			
		end
	elseif enable == false then
		print('Disabled level system!!')
	end
	
end

you tryna perform an addition to CurrentXPData when it isnt a number (its an instance)

So do I have to tonumber the value?

Are you using ProfileService by any chance?

no add something like .Value to the end

Yes, I’m using ProfileService and I’m having hard time understand it. Here is my previous post asking for help about ProfileService:

No point in doing that, will just throw an error. CurrentXPData is not an IntValue, it’s a DataStore value

Ok, I will try it out to see if it work or not!!

oh mb i didnt see that in there

Well, I have been using it as well for my past projects and I could get around your problem by adding this to my DataSystem script:

function DataSystem:AdjustCoins(player: Player, amount: number)
	local Profile = Profiles[player]
	if not Profile then warn(player.Name.."'s Profile Is Nil") return end
	
	Profile.Data.Coins += amount
end
1 Like

Oh ok I will try your code out!!

It Is ok, people make mistakes :smiley:

Tysm for helping, it really worked!! :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.