Not touching hitbox - no enemy founding

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!
    I want to make hitbox which checking is on hitbox any attacking enemy

  2. What is the issue? Its doesnt work, litterly no founding enemy

  3. What solutions have you tried so far? Tried to ask here: How to check if the player is touching & not touching a part?, but no one answer

Script

local touchingParts = workspace:GetPartBoundsInBox(hitbox.CFrame * hitbox.PivotOffset, hitbox.Size)

	for v, part in pairs(touchingParts) do
		local enemy = part.Parent
		if enemy and enemy.Name ~= character.Name then
			local enemyhumanoid = enemy:FindFirstChildOfClass("Humanoid")
			if enemyhumanoid then
				local enemyrootpart = enemy.Parent:FindFirstChild("HumanoidRootPart")
				if combo < 4 then
					enemyhumanoid:TakeDamage(3)
					stunner:stun(1.4, enemy)
				elseif combo >= 4 then
					lasthitted = true
					enemyhumanoid:TakeDamage(4)
					stunner:stun(4, enemy)
				end
			end
		end
		wait(0.15)
		break
	end
3 Likes

Hi, are the parts in the hitbox? If so, use local touchingParts = workspace:GetPartsInPart(hitbox)
This will return a table.

2 Likes

Doesnt work :frowning:

3 Likes

When is your Event being fired? Is it?
Edit: Try printing at different stages to test which part of your code is not working.

now its work


BUT ONE PROBLEM: why hitbox staying on longer time if hitted?
and I also suspect that it works with chance, because I haven’t changed anything since the last time I entered the studio.

That would be done using break at the right time after the hitbox is hit

i`ve add break into script:

if enemyhumanoid then
				local enemyrootpart = enemy.Parent:FindFirstChild("HumanoidRootPart")
				if combo < 4 then
					enemyhumanoid:TakeDamage(3)
					stunner:stun(1.4, enemy)
					break
				elseif combo >= 4 then
					lasthitted = true
					enemyhumanoid:TakeDamage(4)
					stunner:stun(4, enemy)
					break
				end
			end

Result: doesnt work

Nice, no one answering…rahhhhh

just destroy the hitbox if it hits a player

2 Likes