(My problem is that when the fireball touches the Player it doesn't work any more for the enemy which leads to not damaging the enemy.)
local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local Character = Player.Character
local CoolDown = true
mouse.KeyDown:connect(function(key)
if key == "f" then
local Fireball = Instance.new("Part")
local Fire = Instance.new("Fire")
local Velocity = Instance.new("BodyVelocity")
Fireball.Name = "Fire"
Fireball.Material = "Neon"
Fireball.BrickColor = BrickColor.new("Neon orange")
Fireball.Parent = workspace
Fire.Parent = Fireball
Fireball.CFrame = Player.Character.UpperTorso.CFrame * CFrame.new(2,1,-1)
Fireball.Size = Vector3.new(1.5,1.5,1.5)
Velocity.Parent = Fireball
Fireball.Shape = "Ball"
Velocity.Velocity = Player.Character.UpperTorso.CFrame.LookVector * 35
Fireball.Touched:Connect(function(hit)
if hit.Parent then
if CoolDown == true then
wait(0.02)
CoolDown = false
Fireball:Destroy()
Fire:Destroy()
local Enemy = hit.Parent:FindFirstChild("Enemy")
Enemy.Health = Enemy.Health - 10
wait(1)
CoolDown = true
end
end
end)
end
end)
