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

Why isn't there an explosion once it hits?[Solved]

I made a script, it shoots a part, the part welds to what ever it hits, wait 5 seconds, and then explodes. Unfortunately, it isn't blowing up! Why not? Here is my script

function onTouched(hit)
local weld = Instance.new ("Weld")
weld.Parent = hit
weld.Part0 = script.Parent
weld.Part1 = hit
wait(5)
--not my part
ex = Instance.new("Explosion")--Create An Explosion
ex.Position = script.Parent.Position --The Explosions Position Is The Brick
ex.BlastRadius = 2 --A 5 by 5 Explosion.
ex.Parent = script.Parent --You got to be able to see it.
--my part again
hit:BreakJoints()
script.Parent:Remove()

end

connection = script.Parent.Touched:connect(onTouched)

Please help!!! Thank you!!! --this is in a regular script, should it be in local?

8 comments

0

Any output?

0

no that is the problem!

0

You forgot to set C0 and C1 after line 5, that could be the problem.

0

Not setting those properties shouldn't matter. The bricks will simply have the exact same CFrame. @yogi; Add some print statements before and after the wait(5). Are any of them working?

0

yes, all of them are working

1

@adark The exact reason why he mightn't be able to see an explosion.

0

Ah, I see.

0

How do i fix it then?

1 answer

✓ Accepted answer

Here is the right script. It works and you can see the explosion

function onTouched(hit)
    local weld = Instance.new ("Weld")
    weld.Parent = hit
    weld.Part0 = script.Parent
    weld.Part1 = hit
    wait(5)
    local explo = Instance.new("Explosion")
    explo.Parent = game.Workspace
    explo.BlastRadius = 2
    explo.Position = Vector3.new(script.Parent.Position.X,script.Parent.Position.Y,script.Parent.Position.Z)
    hit:BreakJoints()
    wait(1)
    script.Parent:Remove()
end

connection = script.Parent.Touched:connect(onTouched)

2 comments

0

Thank you!!! I understand why it didn't work!

1

Np, however I lost reputation :(

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