[Solved][5smokin is the legend] Raycasting is the best way to replace touched events

My touched event is in a local script that runs on all clients in the server. The bullet explosions are so delayed that they are like 4 or 5 studs ahead of where the bullet is touching. I tried both with debounce and without debounce and both do not work although without debounce is definitely better because it’s even worse with one. What can you do to fix this problem? I’m shooting 100’s of bullets at once but it shouldn’t matter there is no lag just the touch event being delayed. Please help thank you

1 Like

Instead of using .Touched event, you can use raycasting to detect collisions. You can cast a ray from the bullet’s current position to its next position to check for collisions.

1 Like

Raycasting checks any directions? My shotgun has a spread effect and the bullets go infinitely straight towards the direction of the mouse with linear velocity until they touch something. I’ve raycasted before but it was a really scuffed way of doing it using tons of invisible parts lined up a certain way. In other words, I learned the very basics of it but I never learned how to use it for anything important

Raycasting can indeed check in any direction, instead of using tons of invisible parts, you can raycast multiple rays with different directions and detect if the ray hit anything.

1 Like

If you can send me a tutorial you learned with that I can check out when I get back from lunch, I’d really like to watch it and try it myself so I can do it. I just need raycasting to detect if the ray hits anything. I don’t plan on using it for the actual creation of bullets or anything else if that’s okay

There is a lot of tutorials on YouTube but personally I would suggest this one
Learn Raycasting in 7 minutes - Advanced Roblox Scripting

1 Like

I watched https://www.youtube.com/watch?v=YipkISTwGlc and this solved everything. I learned how to raycast and it works absolutely perfectly. Thank you so much for your help my friend :heart:

1 Like