Need help with handling client sided ground slam hit detection on server sided NPCs

So my combat game is heavily reliant on NPCs that spawn around the map, they can fight other NPCs or players and some classes can summon NPCs to help in fights.

This means that there can be a lot of NPCs fighting at once and i have a mechanic where enemies slam into parts after getting thrown by certain abilities. The ground slam raycast hit detection is handled on the server so i want to reduce stress on the server since alot of throws are happening.

I want to make the throw hit detection client sided to reduce stress on the server and fix the hit detection delay on your client when getting thrown.

My issue now is how would i handle the hit detection for my NPCs? How do i choose which player should handle which NPCs hit detection when getting thrown? There will also be a delay when slamming into something depending on the players ping, etc.

I could keep the hit detection for NPCs server sided but as i said earlier i want to reduce server stress.

The slam effects are all client sided but damage, raycasting, stun, etc is all handled on the sever right now.

Here is a clip of me fighting an NPC which throws me a couple of times, the red/green lines are visuals for the raycasts happening.

Sorry if i explained it in a bad way, english isnt my first language.

Checking hits on client is a bad, BAD idea, as it’s extremely vulnerable to exploits. Don’t do it. If you want to reduce server stress, throw it in an actor.

1 Like

Keep the NPC’s hit detection on the server. If it was handled by the client, someone could inject a script into your game that would say the NPC never hit them and thus nothing happens (as an example).

It sounds like you are already handling all the collision stuff server side and all the visual stuff client side with is perfect. As Baj Artembon said, you could look into multithreading your hit detection (running your hit detection on a second thread) which would reduce load on the server. I don’t have any clue how, but this link could be a good starting point

Parallel Luau | Documentation - Roblox Creator Hub

1 Like

I actually meant only the hit detection for smashing into parts after getting thrown, not hit detection all together if that helps.

Also, i don’t think parallel lua works on the server. Even then, i have tried to understand multithreading before but there are no good tutorials on how to use it the way i wanna use it.

Not sure what’s with the aversion to client-sided hit detection in these responses. The client that preforms the throw should be the one running the calculations, and if the client is being thrown (by an NPC, not a player), then they should do the calculations for that as well.

1 Like