Is there a more efficient way to shoot projectiles?

I am making a game where you have guns that shoot bubbles, and I do not want instant traveling bullets so I did this script

When I do this, the bullet travels in the right direction then pauses for like 0.1 seconds then continues traveling, so if you are close to someone then your shots will not hit because of that slight delay.

I believe you should use SetNetworkOwnership() if im not wrong, change it to the server so that it handles it and replicates it properly to everybody:

2 Likes

The way you’re handling parenting, network ownership aside, also plays a part in this. The way you’re doing it is pretty bad for performance. Specifically how you set properties before the parent.

Therefore, I suggest you combine network ownership with appropriate instancing. Set properties, then the parent. After everything’s done, put the bullet in the workspace.

local bullet = Instance.new("Part")
bullet.CFrame = CFrame.new(script.Parent.Barrel.CFrame.Position, mousepos)

local attachment1 = Instance.new("Attachment")
attachment1.Position = Vector3.new(0, 0.12, 0)
attachment1.Parent = bullet

local attachment2 = Instance.new("Attachment")
attachment2.Position = Vector3.new(0, -0.12, 0)
attachment2.Parent = bullet

local trail = script.BulletTrail:Clone()
trail.Attachment0 = attachment1
trail.Attachment1 = attachment2
trail.Parent = bullet

local velocity = Instance.new("BodyVelocity")
velocity.Velocity = bullet.CFrame.LookVector * module.bulletspread

bullet.Parent = workspace
bullet:SetNetworkOwner(nil)
3 Likes