Laggy knockback (linear velocity)

hello everyone! i’m making a pvp game and i made a knockback system that using linear velocity. everything works fine but it laggy. this happens very random and sometimes it laggy and sometimes its not. i need to fix it because this bug can cause some problems in pvp

4 Likes

This is probably not because of your script and stuff, i think its just a bug on Robloxes behalf.

1 Like

Yeah I’ve seen this problem before on a game I’m working on. I don’t think changing the physics stepping settings do much help, and I don’t think there’s a way to let the client do all the physics, as the server needs to track the ragdoll’s position.

1 Like

If you give the ragdoll’s network ownership to the player then it will still be replicated to the server, however the server will get the replication lag instead of it being visible to the player.

1 Like

I’d prefer not to change the network ownership from the server. The attacker could manipulate the ragdoll’s movement to their advantage, and same goes for the player being attacked.

1 Like

This usually happens on NPCs owned by the server. To me it happens once the server is fresh, the lag stops after ~30 seconds. However, this might also be because the ownership of the NPC keeps changing from the server to the player making it seem as if the NPC is lagging

1 Like

It’s because it’s an NPC and the attacking player isn’t the network owner. Roblox should set the network owner of the dummy to the closest player by default, but you can do :SetNetworkOwnership(Player) on the rootpart of the NPC for precision.

2 Likes

I believe the same what @DEVLocalPlayer and @TheCraftNCreator said that its because its a NPC. I have a combat game with knockback of my own and there is no lag when attacking other players. Try going into the test tab in studio and starting a local server with 2 players and let them attack each other and see what happens.

Maybe you can try moving it to the client-side? Other than that there’s not really anything else.

Try doing this:

If attacked character is not a player then do knockback on server and then fire all clients to do knockback.