Bullet replication inaccurate across clients and server

I’m using FastCast for my FPS, however I am getting problems where if you are shooting at a moving target, on your client end it will say you hit them, but the server will say you missed.

What I do is the client clicks and it creates the bullet on their client and it travels, has hit detection, etc. all for the client. When they click, I fire a remote event to the server, with the position you are shooting towards, and the position of origin.

‘Bullet’ is the module that handles client side firing.

	Player,				-- Player who fired
	Character.Weapon,	-- Weapon model
	MousePosition, 		-- To
	FirePoint			-- From

Shoot:FireServer(MousePosition, FirePoint) -- Fire on the server

Then on the server, it does the same thing, but the bullet isn’t created on the server (server just relies on the rays, no aesthetic bullet) and the server also handles hit detection. There server also uses FireClient() to fire to all the clients (minus the client who fired the bullet), so the bullet object is created on all their screens to.

Problem is cause client-server communication is delayed, and your character position on the client when moving is delayed on the server. And I can’t do hit detection on the client for killing the player, as that can be exploited incredibly easily. So what’s the best work around available??

I can’t exactly specify your problem, but I never create skills client side due to the amount of problems created. There was 1 time where I had a magic skill that I created client side and everything worked except when it came to the damage it would show damage but the damage wouldn’t actually be happening. Creating skills client side has too many problems > My solution is to create the skills on the server > but do the effects/detection client side > when theres detection send an event server side to deal the damage. Works perfectly fine for me. I don’t know how much this helps you, but id imagine this way would be better than going down the rabbit hole of creating skills client side.

I do that already, but both client and server have their own hit detection functions.

Client hit detection

  • Shows hit marker cursor

Server hit detection

  • Kills hit player

Just an idea, but have you tried remaking it. Sometimes when I have an error I just scrap the whole thing and the error that was there magically disappears after I remake it. Might be worth the try xd

It’s not an error though. It’s client-server replication issues, remaking it won’t fix anything

I mean if you remake it you could try different ways of making it. Theres a million ways to make one thing > like you’re trying to force this client-side thing, when theres probably a way better an easier solution looking at you in the face. It wouldn’t hurt to scrap and retry making it just saying.

Well that just sounds like lag. On the client, you hit but once the message has reached the server the target has moved and now it doesnt hit anymore. Check wether there is a wall in between origin and hit and let the hit count. You could do other checks as well, maybe the magnitude of the position of the instance you hit with the bullet and its current position.

I can’t do this. My game has bullet drop, as it’s a paintball game. Thus it’s possible to actually shoot someone without even needing to see them

Hit detection shouldn’t be done on the server for projectile based weapons. No matter what you do, there’ll always be inconsistencies. You should fire a Remote Event on the client that fires it whenever the projectile hits an enemy that needs to be damaged/changed, then on the server do some basic sanity checks (distance check or the like)

Exploiting with projectile based weapons is hard to combat, and there isn’t much you can do. Not handling hit registration on the client means bad user feedback and server lag. Just add some sanity checks and if you’re really worried you can handle ammo on the server and maybe do a raycast.

This might be seem like a lot, but I’ve seen way crazier in games outside of Roblox.

Well this really just comes down to lag compensation. I’m not familiar with fastcast but I’ve worked with projectiles in the past and one thing I did was update the approximate delay (or ping) of each player every 5 seconds, but you may want to change that in retrospect to max player count, through mimicking the NTP protocol in Roblox (which was accurate down to .004-.0001 most of the time within a Roblox implementation).

Then, I would calculate the approximate position that the bullet should be at according to the client tick and calculated offset sent by the client, while spoofing delay is exploitable there’s not much of a way I can think of to get around it. I’d really just recommend adding a maximum delay and not firing the bullet at all if that is surpassed to somewhat combat this.

Another thing I did was if the tick was off by a high amount (high ping) I would divide up the time into segments that the client originally fired (with offset) and the server time and loop determine the position at each segment in time then raycast along those points for higher accuracy to avoid raycasting straight from the origin to the compensated position, which would be inaccurate in high latency situations.

Assuming you already have a method for determining bullet position at a given time from original fire, you could also check if the bullet should be anywhere near the hit position by getting the position from bullet fire time to bullet hit time and magnitude check.

If you are scared about server latency, you can just forward the information to all the other clients and then have the server perform the aforementioned sanity check while also requiring a minimum amount of players to confirm the bullet hit a target, since I’ve never really heard of an exploit that allows multi-roblox injection, plus exploiters usually have no friends.

This is just what I did, but I’ve also heard of recording each player position then rewinding according to the delay (such as in CSGO), but I avoided that because I was afraid of server lag in high player counts since its basically freeware servers your game runs on, though this might be more plausible now that I think about it.


If you are to simulate bullets moving, while still keeping hitscan, then I do not see why you are attempting to use a moving projectile instance.

Instead, I recommend using bullet tracers. These can be best done with Beams.


Maybe check the direction of the shot (disregarding the Y-Axis ofc) and it’s magnitude to the expected direction. However there isn’t much you can do. I myself use ricochets in my game, its pretty impossible to verify complicated, realistic bullet physics. Remember, you’re making a game for players not exploiters.