Im not a great programmer but have been really into learning how to script in Roblox lately and this site has helped me learn alot over the past few months.
I am trying to Script a wall that blows up when it is touched by a FireBall. So I made the FireBall launcher tool (which shoots spheres named fireballs)
and then I created a wall named DestructibleWall I then attached a script to the DestructibleWall and wrote the following code.
local function OnTouched(hit)
if hit.Name == 'FireBall'
then
Instance.new("Explosion", game.Workspace)
local explosion = Instance.new('Explosion')
game.Workspace.Explosion.Position = script.Parent.Position
script.Parent:Destroy()
end
end
script.Parent.Touched:connect(OnTouched)
Sadly this is not working. Nothing Happens when the FireBalls touch the wall. I should mention that the FireBalls create Explosions when they touch any object. I'm not sure what I'm doing wrong here. Any advice would be very much appreciated.
Ok, with a quick glance
, I already saw what you had wrong. First of all, you made an explosion, and parented it to workspace, and not settings it's position which causes an explosion to spawn at Vector3.new(0,0,0). Third of all, You made an explosion but didn't parent it to anything. Simply do
Explosion.Parent = workspace
That's basically it, no other errors that I see.