I'm making a power up, you shoot a "Fireball" out of the player and into the workspace. I want to see how I could make it so that when the "Fireball hits something it explodes, but after 60 seconds if the "Fireball" didn't hit anything it just is destroyed. And also on how to make a cool down. I've tried these things out but they didn't work.
Here's the script
local Plr = game.Players.LocalPlayer
local Mouse = Plr:GetMouse()
local Ammo = 1
Mouse.KeyDown:connect(function(key)
key = key:lower()
if key =="f" then
print("F has been pressed!")
local FireBall = Instance.new("Part")
FireBall.Shape = "Ball"
FireBall.BrickColor = BrickColor.new("Maroon")
FireBall.Transparency = 0.5
FireBall.TopSurface = "Smooth"
FireBall.BottomSurface = "Smooth"
local Fire = Instance.new("Fire")
Fire.Parent = FireBall
FireBall.CFrame = Plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-6)
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Velocity = Plr.Character.HumanoidRootPart.CFrame.LookVector * 90
BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BodyVelocity.Parent = FireBall
local Explosion = Instance.new("Explosion")
FireBall.Parent = workspace
Ammo = Ammo - 1
wait(3)
Ammo = 1
wait(1)
FireBall:Destroy()
end
end)

3 comments
Don't use key down it's depreciated user userinput service
and why are you getting your key press from the mouse
im following a tutorial from 2 years ago