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.
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.
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?
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.
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.
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.
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.
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.