How do i handle knockbacks

Hello, I’m trying to make a knockback system in my game, But i have run into an issue. When i was making the knockback system i initially had thought out to just handle it on the server because it would limit the amount of remote event usages etc and it would also be safer. Though because of characters networkownership being the player it didn’t work, So i though of just handling it on the client but that wasn’t a great idea either because then I’d have to use alot of remote events which i don’t want, Not to mention applying knockback on NPC’s would be way harder from the client. Is there any way around this? or am i just doing something terribly wrong, Any help is appreciated.

1 Like

Just set the network ownership of the HumanoidRootPart to the server temporarily using SetNetworkOwner().

1 Like

Would that affect the player getting hit? Like making them unable to change states or such

It might make it a bit unresponsive, but you could probably keep the network ownership transfers short and that should mitigate it a bit.

1 Like

you can handle everything on the server, but when you want to knockback a player you send them a remote event telling them to knock themselves back a certain amount. Then with NPCs you can just do knockback entirely on the server

This way you can keep all your code on the server and have just one small handler for knockback on the client

You cant really make it safer because even if you knockback from the server an exploiter could just cancel their velocity on the client

1 Like

I will try this out thanks for the suggestion