Damaging part does more on first hit

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    A part that hurts.
  2. What is the issue? Include screenshots / videos if possible!
    It does more damage on the first hit.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have a gui which is like a class select thing. The class selector adds hats to the player and changes their walkspeed/health/jumpheight. The starter character had 1 health so it used to just insta kill but I changed the health for the starter character and then this issue popped up.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Note: I am new to scripting.

local debounce = false

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= "Zombie" then
	if not debounce then
		debounce = true	
			hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 3
			wait(math.random(1,2))
		debounce = false
		end
	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

You can create an bool variable that is true and then its false after the damage dealt, if the variable was true then you can add a multiplier to the damage dealt, if its false then you can deal the normal damage

When the code will be runned then the part will damage the player
If its the first time its runned then the damage will be dealt will be multiplied with the boolean variable being true, after that the boolean variable will be false and all the other attemps to damage will be normal

You can reset the extra damage by setting true the variable, the code will look like this

local debounce = false
local extra = true

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= "Zombie" then
		if not debounce then
			debounce = true
			
			local Multiplier = 1
			
			if extra then
				Multiplier = 2 -- Set this multiplier to anything you want
			end
			
			hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - (3 * Multiplier)
			wait(math.random(1,2))
			debounce = false
			
			extra = false
		end
	end
end)

Sorry if I didnt clarify - I meant the issue was extra damage on the first hit. Thanks for trying to help though :slight_smile:

1 Like

If it’s extra damage on first hit by each player, you could create a table consisting of people that has hit the target and do simple check

1 Like