Value being subtracted to negatives

Why is this being subtracted to the negatives?

game.ReplicatedStorage.Events.Removed.OnServerEvent:Connect(function(player, Strength)
	player.Data.Damage.Value -= Strength

What do you mean? The routine just subtracts the value by Strength. If you don’t want it to do that then you’d have to do an if statement after.

when i go in game it starts at 196 but when this is fired it goes down to -196

What value is strength
Also add a print statement to the OnServerEvent to see how many times it’s being called. Same thing for where it’s fired from

Can’t you just remove the negative so it would be

	player.Data.Damage.Value = Strength

I am not sure if I am missing something to the problem…

The player is apparently dealing less damage than what Strength is

Just use math.abs(x), where x is your variable name?

    local Result = player.Data.Damage.Value - Strength
    player.Data.Damage.Value = Result

lets say a player had 100 damage when they equipped an armor, when they sell or unequip it that would subtract it by how much they equipped it with so subtracted by 100

Screen Shot 2021-04-01 at 3.19.13 PM

but if a player had additional Damage that would just remove all of it

So you could do:

game.ReplicatedStorage.Events.Removed.OnServerEvent:Connect(function(player, Strength)
	player.Data.Damage.Value = player.Data.Damage.Value - Strength

I am still a bit confused on what you are trying to do, it might help if you showed us the code you use that triggers the event

Whoops, try it again? Idk if that’ll change anything I mean the updated script I edited

it didn’t print anything because it couldn’t get past the second line

Run print (Strength), perhaps the wrong values is being sent? The function -= is completely valid. It will subtract teh value of your item by what you give it, but it could be that Strength is high. Also, did you check how many times the function is called?

it printed blank

Let me know if this works:

game.ReplicatedStorage.Events.Removed.OnServerEvent:Connect(function(player, Strength)
	player.Data.Damage.Value = player.Data.Damage.Value - Strength

That’s your issue. Something is not being sent correctly. What’s your FireServer() parameters?

I fixed some stuff and it printed some numbers but heres a video

i tried that but it still did what happened in the video

I meant try the updated script again, see if that fixes anything

Are your parameters sent correctly. There is nothing wrong with the OnServerEvent this is completely error of the :FireServer() handling