I've been working on this gun recently and I need to know if there is a better way to detect the bullet hitting an object instead of using the touched event. Whenever I use this way of detection, the network owner switches when it gets too far away or is too laggy when to close up, so touched sometimes didn't fire. So I decided to use :SetNetworkOwner(nil), however that seems to stop the bullets in mid air for a split second after fired, but it does work.
I would like to prevent this frozen state, and would like to know if there is a better way to find a bullet hitting an object.
This is my current code:
local part = Instance.new("Part", plr.Character)
local BodyVelocity = Instance.new("BodyVelocity", part)
part:SetNetworkOwner(nil)
part.CanCollide = false
part.CFrame = cframe(mgCFrame.Position, mP.Position)
part.Size = Vector3.new(.1, .1, 2.5)
part.Material = Enum.Material.Neon
part.Color = Color3.fromRGB(200, 200, 0)

7 comments
raycasting would work pretty great for bullets
If you're not using Humanoid.Touched then that may be your solution, but if you are then idek...
Mr_Pure I'm checking if the bullets get touched not the players
theking48989987 I'm not using raycasting so the bullet can still hit people even if they walk in front of it after it's fired. Just to be clear this is a MOVING PROJECTILE (forgot to mention that))
To create a new CFrame, you have to use CFrame.new(), not cframe()
Serpentine at the top I declared cframe as CFrame.new
Like I said, the script works, it just freezes the bullet in place for a split second. I'm wondering how to get rid of that