I get bad argument #2 to '?' (Vector3 expected, got nil) as an error for this script.
function CreateBullet(Direction) local Origin = GunModel.Barrel.CFrame.p local BulletMass = BulletSize.X * BulletSize.Y * BulletSize.Z local BulletCF = CF(Origin, Origin + Direction) local Bullet = Instance.new("Part") Bullet.BrickColor = BulletColor Bullet.Name = "Bullet" Bullet.CanCollide = false Bullet.FormFactor = "Custom" Bullet.Size = BulletSize Bullet.BottomSurface = "Smooth" Bullet.TopSurface = "Smooth" local Mesh = Instance.new("BlockMesh") Mesh.Scale = BulletMeshSize Mesh.Parent = Bullet local BF = Instance.new("BodyForce") BF.force = Vector3.new(0, BulletMass * (196.2 - BulletDropPerSecond), 0) BF.Parent = Bullet Bullet.Parent = Gun Bullet.CFrame = BulletCF + Direction * 3 Bullet.Velocity = Direction * BulletVelocity end Mouse.Button1Down:connect(CreateBullet)
You need to fire the function with arguments. You are telling it to shoot it toward nil and it wants a Vector3 so You need to fire it like this:
Mouse.Button1Down:connect(function() --Create a formula here to find out what direction to fire it. CreateBullet(Direction) end)