Hit detection issues

Greetings again fellows, Today I need your help.

I am trying to get a railgun to detect hits.
But in game it’s not working, and in studio it is…

In Game:
https://gyazo.com/574faec69ac416620b9630bb65d4d5f4

Studio:

So I don’t really understand why there is such a difference.
My code uses a raycast to determine direction of the bullet and then it uses .Touched to do hit detection. However it apparently only works 1/5 times in game.

I have no idea what to do…

3 Likes

Is this being done on the client or is it being done on the server?

1 Like

I think you should use raycast to also get the part to do damage, and only use the bullet for visual effects. I’ve been looking into this module called Fast Cast and deciding whether or not to use it in my game, here’s a link to it. Making a combat game with ranged weapons? FastCast may be the module for you! (Not sure if it’s good, so I don’t guarantee it.)

I wouldn’t rely on .Touched events for your hit detection. As someone mentioned before, you can emulate a physical bullet with a projectile based raycasting system like the FastCast module.

It basically works by casting multiple rays, where each ray serves as a sort of frame. In each iteration, it checks for a hit, it not, it calculates the rays position for the next “frame”, repeating this until it expires or hits something.

Edit: I love your UI btw.

1 Like

I don’t know how I did it, but it does damage now.

Thanks anyways to everyone who replied

Ok so pls set your or random answer as solution for beter orientation in main menu

3 Likes