Answered by
5 years ago Edited 5 years ago
What I will do is create a touched event and destroy the fireball if it touches something (you can add your own code to deal with what to do with the hit in there)
I will then add the fireball to the debris service so that it will only last for 60 seconds
Afterwards it will wait for the fireball to be destroyed and then replenish the ammo variable.
I kept the cooldown of 3 seconds there.
01 | local Plr = game.Players.LocalPlayer |
02 | local Mouse = Plr:GetMouse() |
04 | Mouse.KeyDown:connect( function (key) |
07 | print ( "F has been pressed!" ) |
09 | local FireBall = Instance.new( "Part" ) |
10 | FireBall.Shape = "Ball" |
11 | FireBall.BrickColor = BrickColor.new( "Maroon" ) |
12 | FireBall.Transparency = 0.5 |
13 | FireBall.TopSurface = "Smooth" |
14 | FireBall.BottomSurface = "Smooth" |
15 | local Fire = Instance.new( "Fire" ) |
16 | Fire.Parent = FireBall |
17 | FireBall.CFrame = Plr.Character.HumanoidRootPart.CFrame * CFrame.new( 0 , 0 ,- 6 ) |
18 | local BodyVelocity = Instance.new( "BodyVelocity" ) |
19 | BodyVelocity.Velocity = Plr.Character.HumanoidRootPart.CFrame.LookVector * 90 |
20 | BodyVelocity.MaxForce = Vector 3. new( math.huge , math.huge , math.huge ) |
21 | BodyVelocity.Parent = FireBall |
22 | local Explosion = Instance.new( "Explosion" ) |
24 | FireBall.Touched:Connect( function (hit) |
28 | FireBall.Parent = workspace |
30 | game:GetService( "Debris" ):AddItem(FireBall, 60 ) |
34 | while FireBall.Parent do |