Hitbox made with OverlapParams damages player too much

Hello devs! So I’m using OverlapParameters for my hitboxes, but there’s issue, it damages player too much, like if I want to take 5 health from player, it takes more, I know the issue is the part amout, but I don’t know how to fix it.

Here is my current code :

local attack1 = script.Parent.Parent.Monster.Animator:LoadAnimation(script.Parent.Parent:WaitForChild("Attack1"))
local attack2 = script.Parent.Parent.Monster.Animator:LoadAnimation(script.Parent.Parent:WaitForChild("Attack2"))

local op = OverlapParams.new()
op.FilterDescendantsInstances = {script.Parent.Parent}
op.FilterType = Enum.RaycastFilterType.Blacklist

coroutine.wrap(function()
	while task.wait(script.Parent.Parent.Configuration.DamageDebounce.Value) do
		local op = OverlapParams.new()
		op.FilterDescendantsInstances = {script.Parent.Parent}
		op.FilterType = Enum.RaycastFilterType.Blacklist
		local parts = workspace:GetPartsInPart(script.Parent,op)
		if parts then
			for _,hit in pairs(parts) do
				if hit.Parent and hit.Parent ~= script.Parent.Parent and hit.Parent:FindFirstChildWhichIsA("Humanoid") then
					local hum = hit.Parent:FindFirstChildWhichIsA("Humanoid")
					local random = math.random(1,2)
					if random == 1 then
						attack1:Play()
					elseif random == 2 then
						attack2:Play()
					end
					hum:TakeDamage(script.Parent.Parent.Configuration.Damage.Value)
				end
			end
		end
	end
end)()

(This script can be placed in any part, just chance some stuff.)

PS : There may be grammar mistakes in this topic.

But you aren’t changing your debounce to true (assuming you have it set to false originally) at the beginning of your function. I’m not a great scripter, but it seems that you are just using wait(script.Parent.Parent.Configuration.DamageDebounce.Value) to wait the length of your DamageDebounce.Value
Don’t you need to use a debounce false/true check to stop the coroutine from being fired multiple times?

I need solution to my problem, not debounce problem.

Oh wait debounce fixed the problem, I used break when player was damaged.

1 Like