Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make my fireball explode when it touches something?

I want to make it so that when I fireball touches ANYTHING it explodes. How do I do this? Also, sorry if my code is hard to read and if it sucks... Forgive me

This is my fireball code...

Code:

local Player = game.Players.LocalPlayer
local char = Player.Character or Player.CharacterAdded:Wait()
local head = char:WaitForChild("Head")
local ammo = 1

local x = Instance.new("Part")
	x.BrickColor = BrickColor.new("Maroon")
	x.Shape = "Ball"
	x.Material = "Neon"
	x.TopSurface = "Smooth"
	x.BottomSurface = "Smooth"
	x.Anchored = false
	x.CanCollide = true
    x.Transparency = 0.5
	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 animation = Instance.new("Animation")
				animation.AnimationId = "http://www.roblox.com/asset/?id=855830361"
	local humanoid = script.Parent:WaitForChild('Humanoid')
          		humanoid:LoadAnimation(animation):Play()
  wait(1.5)

if ammo == 1 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 
       			cl.CFrame = Player.Character.UpperTorso.CFrame * CFrame.new(0,1,-5)
				ammo = 0
				game.Debris:AddItem(cl, 4)
				wait(2)
				ammo = 1
		end			 										
    end
end)


1 answer

Well, what we want to do here is make a new instance of an explosion when it hits something. So, here's the code.

cl.Touched:Connect(function()
WhatheBOOM= Instance.new("Explosion")
WhatheBOOM.Position = cl.Position
WhatheBOOM.Parent = game.Workspace
end)

You can add more properties like

WhattheBOOM.BlastPressure = What ever you want

If you want cl to dissapear you can do right before end)

cl:Destroy()

2 comments

0

LMAOOO! I love your variable name. Tysm! I actually did the same, but it wasnt working because I parented the Explosion to the copy instead of the workspace HAHA TYSM!

0

Ur welcome! If you dont mind, can you please accept my answer?

This discussion is preserved as it was. New answers, comments, and votes are closed.