Touched Event Alternatives?

I am currently working on a project that contains several different types of collisions, such as punches, explosions, beams, etc. Using parts and creating a listener for the touched event, works fine, until players with poor connection play, then the touched event is never even fired.

For Explosions, it is easy, I will simply get a list of humanoids, check if any are nearby and deal damage.

But for things like punches, which need to have a Cube Hit box, difficult. The cube sizes range from
2x2x2 to 10x10x10. What methods do you suggest for this?

2 Likes

checck how close the playr is to the object

if x.Position - y.Position <= 20 then
– scrpt
end

I need hit boxes to maintain their cube/rectangular shapes.

Also to get distance formula correctly, you need to use .magnitude.

local dist = (x.Position - y.Position).magnitude

You could use Hitbox:GetTouchingParts() (say, every time you swing your fists). It’s more accurate than .Touched.
However, raycasting is more accurate and is apparently less resource intensive. There’s a module you can find here:

You can easily use fists with this module (people have done it already) and it supports all types of hitboxes. If you’re looking for something simple, that’s the way to go. But if you’re advanced and want to create your own raycasting system, that module is a good place to start.

1 Like