Just wondering if this is a good idea to stop a dash

For my game I want to make it so if someone punches you mid dash it cancels your dash. However the client handles the velocity of the dash, and the hitbox is on the server. So for people who are aware of what this means it would cause latency which means the player who gets hit would still be moving in the direction of their dash instead of immediately stopping.

As a solution for this, I figured a good way to solve this problem would be to set the velocity on the server (to something like Vector3.new() to stop movement) if they get punched, and anchor the user for a split second or less. This wouldn’t be a 100% fix, but it may be more reliant than checking if the player’s been hit on the client because instead of waiting for their client to receive the message of being hit, we’re acting on the server.

If anyone has a better idea on how to handle this, feel free to explain your thoughts.

1 Like

The data has to replicate to the client one way or another. Changing properties on the server just means that Roblox does it automatically for you. I don’t see how your proposed method that changes anything.

1 Like

Since the script that handles the hitting is on the server, adjusting their velocity on the server would be instant. And if I were to anchor the character on the server at an instant then it would stop immediately for everyone especially the person who threw the punch and connected.

Because of the communication from server to client the dash is handled on the client. So if I were to wait for the signal of the hit on the client it would cause delay. However if I were to do the above method it would still delay for those who have reeeally bad ping, but for those with somewhat decent ping it would likely stop the dash immediately not only that but readjust the player’s position on the client once the client has realized what has happened. So likely the character may teleport back to the position they were meant to be at.

I don’t think this is a bad idea not only but if I were to add ping prediction to this method it may fix my problem completely.

EDIT: Adjusting their velocity on the server wouldn’t be instant but anchoring their character on the server would be instant and would update their position on the client to where they were anchored on the server.

1 Like

I don’t fully understand. The best thing would be to test it out and see if it works.

There is no way of circumventing ping.

What you might be looking for is to stop the player that is dashing on the client of the player that hit it. That way the player that hit them sees them stop instantly. The only thing is the dasher might be in a different position on the hitters client and on the server and everyone else’s client.

1 Like

Yeah like the method I’m doing is basically both client + server. Since I’m anchoring them on the server and setting their velocity to 0 so they stop moving, it should update their position on the client once received.

So yeah if it doesn’t work I could probably just do client only. Hopefully it works though, I know I made some knockback system that was handled with cframe on the server and it worked instantly for both clients. Only problem was choppiness which I decided was best to be done on the client. But since it was instant on the server something like this may work.

1 Like