Hello! I tried looking if a question like this was already asked. but I did not find anything so if it already asked, im sorry. Anyways, I want to make it so that when my fireball has been launched after pressing the e key, it will disappear after 4 seconds instead of still existing.
Here is my code:
local Player = game.Players.LocalPlayer
local char = Player.Character or Player.CharacterAdded:Wait()
local head = char:WaitForChild("Head")
local x = Instance.new("Part")
x.BrickColor = BrickColor.new("Maroon")
x.Shape = "Ball"
x.CanCollide = true
x.Transparency = 0.5
x.TopSurface = "Smooth"
x.BottomSurface = "Smooth"
x.Size = Vector3.new(3,3,3);
local y = Instance.new("Fire")
y.Size = 15
y.Heat = 5
game:GetService("UserInputService").InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
local cl = x:Clone()
local cly = y:Clone()
local v = Instance.new("BodyVelocity")
v.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
v.Velocity = Player.Character.UpperTorso.CFrame.lookVector * 60
v.Parent = cl
cly.Parent = cl
cl.Parent = game.Workspace -- You forgot to Parent it
cl.Position = head.Position + (head.CFrame.lookVector * 2)
-- Position of head + push it in the direction the
-- player is looking and * 2 away from the player
end
end)
Also, I am sorry if my code is really bad, I just started scripting 4 days ago! :D

3 comments
Right after setting your position, you could add in: "game.Debris:AddItem(cl, 4)". This will delete the object 4 seconds after it has the method is called.
ty!
why would you answer in a comment ;-;