Need help with parttouched hit detection

The .Touched event only fires when a part collides with another part. If the .Touched part is gone before any parts bump, you are going to need to use a different method at getting touching objects.

You could try using :GetTouchingParts(), or a Region3 and Workspace:FindPartsInRegion3().

1 Like

Yea, a script preview or such would be helpful as well as any errors in output if such :slight_smile:

Right, so basically to renderstep I check if the hitbox exists and if it does then it checks every single frame that that hitbox exists for a hitpart, after hitting something it adds the hitpart to a table and if that hitpart is in the table then it wont deal the effect to that specific hitpart. And the hitbox’s detection itself uses part.Touched and the GetTouchingParts method.

https://gyazo.com/cf46bf97a5165c8a5df11bcc256f112e
Here is a video of my problem.

Instead of trying to figure out what the character is touching, why don’t you just cast out a Ray in front of the character a few studs, and see if it collides with anything?

Since you are using a table, have you considered checking everything that’s in the table with prints?

Actually I want my script to have a certain hitbox, I have done raycasting for hit detection in my previous works, however, for this game I wanted freedom to control hitboxes for my punches.

As you can see each hit has its own hitbox.

https://gyazo.com/cd2d8b87d32de816a4853c6ae08a4170

No I haven’t yet, I’ll try it and reply.

I asked if you checked everything that’s in the table with prints, because it could potentially be that the .Touched event is maybe firing but the method you used to call the effects on the hitpart may be the issue.

For Instance, if the part is still touching make these effects.

The problem I have with printing all the hit parts is that it severely lags my studio so I can’t capture the bug with it.

https://gyazo.com/3a2430c261c10be06b7cfd385b0fbd54

And yes, it did print the hitparts

https://gyazo.com/e2f724c0ecb4123a14bbe4f88465129d

So what method are you using to produce the effects of the hit?

If you aren’t already, try to call the effects before adding the part to the table.

I think raycasting is the best solution for melee combat detection, but If you are certain you want to use a system like this, you should use Region3’s in my opinion.

You can use the function in this(or a much simpler function like this, if you so not care about the orientation aspect) post, in order to convert your part into a Region3. Then you can just use workspace:FindPartsInRegion3() to get a list of all objects inside the area.

This is going to give you the most consistency in your checks.
The only downside is that Region3’s can be performance heavy in some cases.

1 Like

It checks if the hitpart is hittable then it creates a mesh part(the effects are just a mesh part) at the CFrame of the object hit, if the hitpart has a parent and that parent has a humanoid then it damages the humanoid and adds the humanoid to a hitHums table. If that humanoid is in the hitHums table then that hitBox wont deal damage to that specific humanoid again.

I don’t think it is a problem with the hitdetection rather a problem with the creating of the part itself.

1 Like

Randomly one of the hits in the combo will just not create a hitbox as shown in the gif below

https://gyazo.com/e64287a87d27cfd666ed14935752b473

I have slowed it down and (left hand) is having trouble touching the thing

1 Like

As far as I can tell, the way your describing it your code should work. It may be that the .Touched event is slightly faulty. As @ExcessEnergy described, raycasting may have been a better solution.

The .Touched event sometimes doesn’t fire (at random). The GIF you have sent is clear proof of this. If we had obtained the results from the parts touched, We might have found that the “hitpart” isn’t being hit.

The .Touched event is not an “IsTouching” event and it has the ‘ed’ for a reason. Maybe as soon as it touches the part was added to the table.

1 Like

The green part is the part that registers hits not the arm.