Help fixing raycast delay on server

Hey, I’ll have a video of what I mean below. I know it’s because of a client to server issue but I wanna know if there are any possible fixes.

Basically I’m making a sword for my game, however when I fire a remote event to the server for the raycast it’s where the Character is on the server instead of the client meaning there’s delay, is there any fix to this?

Another issue is that there’s a delay with remote events, I thought of using a tool instead but it still causes the main issue.

Red is the servers raycast and Blue is the clients raycast

1 Like

You could send your local character’s position to the server when you make an attack, then use that for the raycast instead. I’d put a distance check in there to make sure the player isn’t cheating though.

Also the opposite can occur where an enemy is no longer in the same position as they were on the client when the client reports an attack to the server. You can somewhat fix this by making a list of positions the enemy was at then “rewinding” their hitbox based on the attacker’s ping.

1 Like

Thanks, I’ll go ahead and try this right now, I’ll let you know if it works.

Also I haven’t made any AI yet but that’s a good idea

1 Like

Raycasts for this sort of stuff should be done on the client and sanity checked on the server.

3 Likes

I think the server raycast is their sanity check in this case.

1 Like

It works! Also the remote event is mainly there because I cant kill a humanoid on the client pretty sure.

Anyways here’s a video showing it:

Edit: Also I’m not sure how to send a raycast with a remote event without it getting exploited

1 Like