{FIX} Problem with points and table

  1. What do you want to achieve? For example, we have 11 points and when pressed, if a person has more than 10 points, he takes away 10 points and gives “XP” 5 if we have, for example, 6 Then when pressed, he minus 5 XP and gives “1 Level” we have 1 Xp left

  2. What is the issue? The problem is that it “Resets” everything When you click on “Part” it gives 1 But the level is saved

local Part26=script.Parent
local clickDetector=Part26.ClickDetector

clickDetector.MouseClick:Connect(function(player)
	
	local XP = player.leaderstats.XP 
	local PlayerPoind = player.leaderstats.Points
	PlayerPoind = 1
	local level = player.leaderstats.level
if PlayerPoind.Value >= 10 then
		PlayerPoind.Value =  PlayerPoind.Value - 10 
		XP.Value =  XP.Value + 5
		if XP.Value >=5 then
			XP.Value =  XP.Value - 5
			wait(0.1)
			level.Value = 1
		end
	end

end)
  1. What solutions have you tried so far? Searched but didn’t find

Do you mean:
“If the Player has 6 experience points, it will subtract 5, and Add a Level?”

You are telling the code that Instances Value is now 1, instead of adding to it:

You should be doing this:

level.Value = level.Value + 1

-- or if you want a simpler Method:
level.Value += 1 -- Simplified
1 Like

«Если у игрока 6 очков опыта, он вычтет 5 и добавит уровень?»
Yes and left 1 xp

Found solutions And here is the correct script

	local XP = player.leaderstats.XP 
		if PlayerPoind.Value >=6 then
			PlayerPoind.Value -= 3
			XP.Value =  XP.Value + 2
			if XP.Value >=6 then
				XP.Value  -=5   
				wait(1)
				level.Value = level.Value + 1
	
                    end
		end
	 end
 end)

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