Here's the local script, and thank you for looking at my question.
Player = game.Players.LocalPlayer Gun = script.Parent Ammo = 5 mouse = Player:GetMouse() function Shoot() if Ammo > 0 then local Bullet = Instance.new("Part", workspace) game.Debris:addItem(Bullet, 2) Bullet.Shape = "Ball" Bullet.Size = Vector3.new(0.2, 0.2, 0.2) Bullet.TopSurface = "Smooth" Bullet.BottomSurface = "Smooth" Bullet.BrickColor = BrickColor.new("Dark stone grey") Bullet.CanCollide = false Bullet.CFrame = Gun.Handle.CFrame Bullet.CFrame = CFrame.new(Bullet.Position,mouse.Hit.p) local v = Instance.new("BodyVelocity", Bullet) v.velocity = Bullet.CFrame.lookVector * 90 v.maxForce = Vector3.new(math.huge, math.huge, math.huge) end end
Everything is correct, but my Firing Projectile still won't fire. Can you help me? Thank you!
You need to use an event in order to get the 'shoot()' function to work. I would recommend using UserInput, like so;
serv = game:GetService("UserInputService") serv.InputBegan:connect(function(input) if serv.MouseEnabled then if input.UserInputType == Enum.UserInputType.MouseButton1 then shoot() end end end)
I'd give a more through explanation of each line, but I'm on mobile. Still, hope this helps. :)