Weapon projectile pausing then firing?

Pretty much I am trying to make a projectile gun script based off the old ice shard scripts from back in the day however when I go to shoot, the bullet stops for about a second then fires as normal. I reviewed my code and I’m not understanding what is holding it up.

weapon = script.Parent
barrel = weapon.Barrel

local pewpew = Instance.new('Part')
pewpew.BrickColor = BrickColor.new('Really red')
pewpew.Material = Enum.Material.Neon
pewpew.Transparency = .4
pewpew.CanCollide = false
pewpew.Size = Vector3.new(0.1, 0.1, 1.5)

weapon.Events.Fire.OnServerEvent:Connect(function(plr, mouse)
if weapon.Stats.Mag.Value >= 1 then
weapon.Stats.Mag.Value = weapon.Stats.Mag.Value - 1
fire(mouse, mv)
print('yeay shooting') else
if weapon.Stats.Mag.Value <= 0 then
print('o no')
end
end
end)

function computeDirection(vec)
local lenSquared = vec.magnitude * vec.magnitude
local invSqrt = 1 / math.sqrt(lenSquared)
return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
end

mv = 100
function fire(mouse_pos, mv)
if barrel == nil then return end
local dir = mouse_pos - barrel.Position
dir = computeDirection(dir)
local launch = barrel.Position + .1 * dir
local delta = mouse_pos - launch
delta = delta / (delta.magnitude)
local bullet = pewpew:clone()
bullet.CFrame = CFrame.new(launch, launch + dir)
bullet.Velocity = delta * mv
bullet.Parent = game.Workspace
bullet.Touched:connect(hit)
end

It could be the physics delay? If you are using roblox physics there is a short delay when you first fire. Some people use raycasts instead to avoid the delay

1 Like

Maybe you could try tinkering with constraints, springs, or the old body movers.

1 Like

Or maybe TweenService or even RunService if you need to do it manually and combined with raycasting.

Also, I’m not sure if .Touched will be too successful for a fast, small bullet (could be wrong). Maybe you could combine raycasting and the bullet effect.