RemoteEvent multiplies value instead of adding just ONE

  1. What do you want to achieve? Add just one number to value instead of multiplying it by three

  2. What is the issue? It multiplies by three and sometimes even higher even though humanoid health is lower and meets threshold.

  3. What solutions have you tried so far? Tried checking if humanoid is dead or not and still wouldn’t work.
    Please note this is just a cropped version of the event of which it handles dealing damage and giving value.

Events.Finish.OnServerEvent:Connect(function()
local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
Target:FindFirstChildOfClass("Humanoid"):TakeDamage(35)
if Target:FindFirstChild("Humanoid").Health <= 0 and Target.Values.Downed == true then
			if plr then
				plr.leaderstats.TIX.Value += 37 -- Both values are affected
				plr.Stats.KillStreak.Value += 1  -- Both values are affected
		end
    end
end)

Would adding a debounce fix the issue?

There is a debounce but that didn’t fix it either, the player could still fire the event even though the “Target” is dead causing the value to multiply.

Are you sure, that you have done the Debounce properly?
It seems, that each time it hits, it fires as you mentioned, multiple times. This could be due to the debounce you have made not working, so I’d suggest looking more at the Debounce script.

You could also add a debounce on the server.

the debounce is between the damage and it uses three waits
one that is wait(0.2)
sets finishing value to true
then the main wait(1.7)
it does the damage
then finally wait(0.6)
the finishing value is set to false and the player receives the value cash.

Yes, it is between the damage, but the event touches more times.

Need to show code on where you’re firing from.

The event is fired from an user input (E) and its usually fired by the tool holder.
Here it is

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		Events.Finish:FireServer()
	end
end)
	Events.Finish.OnServerEvent:Connect(function()
				local animation = game.ReplicatedStorage.Animations.Bat.Finish
				local humanoid = PlayerCharacter:FindFirstChildOfClass("Humanoid")
				if humanoid then
					local animator = humanoid:FindFirstChildOfClass("Animator")
					if animator then 
						local animtrack = animator:LoadAnimation(animation)
						for _, f in pairs(workspace:GetDescendants()) do
-- rest of script (just does damage to Target)

this is the beginning of the code where do i put the debounce in?

That’s not an efficient ‘debounce’ at all, thats just gonna spam it if they keep pressing E.

Why are you looping through workspace descendants???

That’s the only way i can get the downed character model.

Is there any ways to prevent that sort off? Thank you in advance!

Edit: Added print statements to the script and it is fired three times it seems for whatever reason :frowning_face:
image
any ideas on how i can solve this please?

Here is the snippet script:

task.wait(1.8)
 print("They're done.. awarding player")
  humanoid.WalkSpeed = 16
	if Target:FindFirstChild("Humanoid").Health <= 0 then
      print("Almost Awarding")
	    local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
			if plr then
				print("Awarded!")
				 plr.leaderstats.TIX.Value += 25
				  plr.Stats.KillStreak.Value += 1

Is this inside the for loop or no…?

Yes it is.

This text will be blurred

I don’t get why you’re doing that…? If your code can actually be posted correctly and not in segments, you have a for loop inside of a server event, and then it just changes a players values in it, repeatedly.

The loop doesnt have to do with anything, only the damage and value changers are running three times, could debounce fix this?

It doesn’t seem like you’re breaking the loop at all, that’s causing it to run 3 times…

this has never happened to me, but if you divide it by 3 as well it might work (although it might be a hassle)