Here's the local script, and thank you for looking at my question.
01 | Player = game.Players.LocalPlayer |
02 |
03 | Gun = script.Parent |
04 |
05 | Ammo = 5 |
06 |
07 | mouse = Player:GetMouse() |
08 |
09 | function Shoot() |
10 |
11 | if Ammo > 0 then |
12 | local Bullet = Instance.new( "Part" , workspace) |
13 | game.Debris:addItem(Bullet, 2 ) |
14 | Bullet.Shape = "Ball" |
15 | Bullet.Size = Vector 3. new( 0.2 , 0.2 , 0.2 ) |
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;
1 | serv = game:GetService( "UserInputService" ) |
2 | serv.InputBegan:connect( function (input) |
3 | if serv.MouseEnabled then |
4 | if input.UserInputType = = Enum.UserInputType.MouseButton 1 then |
5 | shoot() |
6 | end |
7 | end |
8 | end ) |
I'd give a more through explanation of each line, but I'm on mobile. Still, hope this helps. :)