How to fix gun tool lagging?

Ok so I have made a “gun” tool and I’ve made it work but there is a problem, the bullet comes out after like a .5 sec lag thingy
(As you can see the bullet is coming out after a delay)
Here is a video of it showing :

My code is here :




script.Parent.OnServerInvoke = function()
	local newBullet ="Part")
	newBullet.CanCollide = false
	newBullet.Material = Enum.Material.Neon
	newBullet.Size =,0.5,1.5)
	newBullet.BrickColor = BrickColor.Red()
	newBullet.Parent = workspace
	newBullet.CFrame = script.Parent.Parent.PointOut.CFrame + script.Parent.Parent.PointOut.CFrame.LookVector
	local bodyPosition ="BodyPosition")
	bodyPosition.Parent = newBullet
	bodyPosition.D = 15000
	bodyPosition.Position = script.Parent.Parent.PointOut.CFrame.Position + (script.Parent.Parent.PointOut.CFrame.LookVector * 1250)

I’m trying to look for some help please if you know how to fix it reply it to this and thank you for reading my post! :slight_smile:

  1. Try setting the newBullet’s network ownership to the player casting it and calculate / detect serverside if the part is going to hit something.

    If you do not set network ownership, the ownership could switch over to other players when shooting at them

  2. maybe the “lagg” will be less when using a serverscript only and not use a remote to handle this on the server.