Better way to make Bullets?

Hello!
I made my first gun recently that fires bullets from a tool. There is a delay in the shot and it’s not super accurate so I was wondering if there is a better way to shoot bullets. Here are my scripts:
Here’s a LocalScript inside of the Tool Handle:

local gun = script.Parent

local replicatedStorage = game:GetService("ReplicatedStorage")

local RemoteEvent = game.ReplicatedStorage:WaitForChild("TennisBall")

gun.Parent.Equipped:Connect(function(mouse)

mouse.Button1Down:Connect(function()

RemoteEvent:FireServer(gun.Position, mouse.Hit.p)

end)

end)

And here’s a script in ServerScriptService:

local replicatedStorage = game:GetService(“ReplicatedStorage”)
local RemoteEvent = game.ReplicatedStorage:WaitForChild(“BulletCreator”)

RemoteEvent.OnServerEvent:Connect(function(player,gunPos,mousePos)

local Bullet = Instance.new("Part")
Bullet.Name = "Bullet"
Bullet.Parent = game.Workspace
Bullet.Shape = Enum.PartType.Ball
Bullet.Size = Vector3.new(1.5, 1.5, 1.5)


local distance = (mousePos - gunPos).magnitude
local speed = 500
Bullet.CFrame = CFrame.new(gunPos,mousePos)
Bullet.Velocity = Bullet.CFrame.lookVector * speed

wait(3)

Bullet:Destroy()

end)

Any suggestions are appreciated. Thanks!

I think Fastcast will be the best option to use for guns :slight_smile:

1 Like

Part of the delay may be n the creation of the part itself, which is why PartCache was made and I think the Fastcast sample gun uses the system.

1 Like

I apologize for not responding sooner. Actually the part spawns, the delay is in the shooting. When I shoot it the part spawns and then shoots.

Put the bullet’s parent at the end of the code. This can be why you have a delay.

1 Like