Why is value being added but not subtracted?

I added an else statement and it printed “No Thanks” 19 times

elseif condition == "Un-equipped" then
		for index, equippedArmor in pairs(plr.Character:GetChildren()) do
			if equippedArmor:IsA("Model") then
				equippedArmor:Destroy()
				print(dpsval)
				plr.Data.Damage.Value = plr.Data.Damage.Value - dpsval
			else
				warn("No thanks") --Printed this 19 times
			end
		end
	end

It’s something going on the dps value, where are you retrieving it?

What do you mean?

Where are you getting the dps value from the client?

local dps = player:WaitForChild("Data").EquippedValue

Hmm, may I see the full code related to the client? Cuase I see nothing wrong in the server

local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local dps = player:WaitForChild("Data").EquippedValue
local holder = script.Parent.Parent.Holder 
local Events = game.ReplicatedStorage.Events
local folder = script.Parent.Parent.Inventory.Duplicates
local dpsval = dps.Value
for index, child in pairs(script.Parent:GetChildren()) do
	if child:IsA("TextButton") then
		child.MouseButton1Click:Connect(function()
			if child.Name == "Equip" then
			if child.Text == "Equip" then
					for index, armor in pairs(folder:GetChildren()) do
						if armor:IsA("ImageButton") then
							if armor.IsSelected.Value == true then
								armor.Equipped.Value = true
								armor.IsSelected.Value = false
								Events.EquipArmor:FireServer(armor.Name, "Equipped", dpsval)
								print(dps.Value)
								
								script.Parent.Visible = false
							else
								armor.Equipped.Value = false
							end
						end
					end
				elseif child.Text == "Un-equip" then
						for index, armor in pairs(folder:GetChildren()) do
							if armor:IsA("ImageButton") then
								if armor.IsSelected.Value == true then
									armor.Equipped.Value = false
								armor.IsSelected.Value = false
							
								
								Events.EquipArmor:FireServer(armor.Name, "Un-equipped", dpsval)
									print(dps.Value)
									script.Parent.Visible = false
									end
								end
							end
						end
			elseif child.Name == "Cancel" then
				for index, armor in pairs(folder:GetChildren()) do
					if armor:IsA("ImageButton") then
						if armor.IsSelected.Value == true then
							armor.IsSelected.Value = false
						end
					end
				end
				script.Parent.Visible = false
				end
			end)
		end
	end

I’m not sure if this will help but maybe change

plr.Data.Damage.Value = plr.Data.Damage.Value + dps

to this?

plr.Data.Damage.Value += dps

Now it’s just not adding any value and is not being subtracted

The value gets added when i do this

local dps = plr.Data.EquippedValue.Value

Wait if it was part of the palyer why couldn’t you just get the value doing that rather than sending it via remoteevent

im not sure because i tried subtracting that with getting the players data but it didn’t work

Try it out again and see if just getting the reference of dps from the player rather than giving it yourslef will do it

It printed this
Screen Shot 2021-04-02 at 9.33.14 AM

It does taht cause it loops through all your children in your character, I presume it’s not printing the value of dps? If not, then it’s not finding a single model in your character

it printed the value, which was 192

It printign No thanks 19 times cause it looped through your character’s children, so it was not a model, and warned you

thats strange because when i looked in player there was an armor model and then when it was unequipped the model was destroyed

Again, it goes through everything, you shouldn’t be worried about the warns if your code is working now

but the value isn’t getting subtracted. Do i use another remote and talk from server to server if that is possible?