Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Getting an explosion to play/spawn when a brick is touched?

Asked by 8 years ago

I've got the touching the brick part and pretty much everything else, however I don't know how to do the explosion part. This is what I have so far, not sure if any of this is how it's supposed to be done though.

wall = game.Workspace.RocksideGlitchbombWall
bomb = game.Workspace.Glitchbomb
explosion1 = Instance.new("Explosion",bomb)

function OnTouched() 
    wait(.5)
    wall.CFrame = CFrame.new(75.5, 10.5, 8)
    wait(1)
    bomb.CFrame = CFrame.new(86, 20, -4)
    wait(1)
    bomb.Anchored = false
    wait(3)
    explosion1.BlastRadius = 30
    bomb.Transparency = 1
    wait(15)
    bomb.CFrame = CFrame.new(85, -40.874, -5)
    wall.CFrame = CFrame.new(75.5, -50.5, 8)
end

1 answer

Log in to vote
1
Answered by 8 years ago

Disclaimer: I am only using answers because it won't allow me to comment don't down vote because I didn't give an correct answer

I am not a expert but I think at the bottom before the end you should have some type of connection to connect to the function, It should go like this:

wall.CFrame = CFrame.new(75.5, -50.5, 8)

wall.Touched:connect(OnTouched) -- Because there is a bomb AND a wall Idk which one you would do sorry
end -- Some people do end) but I think right now end is just fine


I also found another Function connect system:

wall = game.Workspace.RocksideGlitchbombWall
bomb = game.Workspace.Glitchbomb
explosion1 = Instance.new("Explosion",bomb)

function OnTouched(bomb) -- Added the hit part 
    wait(.5)
    wall.CFrame = CFrame.new(75.5, 10.5, 8)
    wait(1)
    bomb.CFrame = CFrame.new(86, 20, -4)
    wait(1)
    bomb.Anchored = false
    wait(3)
    explosion1.BlastRadius = 30
    bomb.Transparency = 1
    wait(15)
    bomb.CFrame = CFrame.new(85, -40.874, -5)
    wall.CFrame = CFrame.new(75.5, -50.5, 8)
bomb.Touched:connect(OnTouched) -- Connecting to the "function OnTouched(bomb)"
end

So basically the first one was a connect(function - receiver method and second one was connectFirst(function - receiver which connects the function first before any other receiver, Idk if any of them works it is a suggestion, Like I said They won't let me use comments so I hope I helped

0
I decided to just start over and 'fake' the explosion with particles and a kill brick and such. I didn't know really what I was doing anyways. crabbyninja 58 — 8y
0
If you wanna shortcut you can get a part and make it so when a part is touched you can Instance.new("Explosion") in the part, I think it is a easy way and it might work. spiderman90438 17 — 8y
Ad

Answer this question