My bullet is laggy on the server

I want to make a bullet and I made a pretty good one but the bullet never worked too nicely,
and I finaly found something that works, but it’s very laggy on the server side.

Server___________________________________Client

As you can see that there’s some obvious lag going on.
I want to fix this if you know how to fix it please let me know.
This is the code that I’m using.

	PreparedBullet.BodyVelocity.MaxForce = Vector3.new(1e6,1e6,1e6)
	PreparedBullet.BodyVelocity.Velocity = CFrame.lookAt(RootPartPos, NewPos).LookVector * BulletInfo.Speed

if you nees anything else please let me know.

1 Like

Might have something to do with NetworkOwnership since the bullet uses physics. That would be the first thing I check out

I did try making the client the owner but the bullet just fell through the ground on the server,
I also tried it by making the owner server, but that caused the bullet to go laggy on the client and on the server

How is the bullet created? It should be done via remote events (where the client sends a signal to the server which then creates the bullet) so that the server manages everything. Note that latency is unavoidable but you can try your best to make it less visible for the players.

NEVER let the client be in charge of the bullets, otherwise exploiters can manipulate them and cheat in your game (They can for example teleport the bullets into targets, essentially giving them aimbot)

1 Like

don’t worry I’m not that stupid :laughing:
and yes I am making the bullet on a server script not on the client

1 Like

In that case, try not to have the bullets rely on physics since the physics engine will always screw you over. You can perhaps try using TweenService to tween the bullets, or manually CFrame them.

I’m more familiar with the second alternative so I’m going to explain that method to you:
You have a table that stores information on all of the bullets. Every heartbeat, you would iterate over that table and update the bullets by moving them with CFrames, raycasting forward for hit registration, or checking a timer to see if the bullet “expired,” etc. If you want to delete a bullet, just remove it from the table; and vice versa if you want to spawn in a new bullet.