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

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

Asked by 9 years ago

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?

0
Any output? Muoshuu 580 — 9y
0
no that is the problem! yogipanda123 120 — 9y
0
You forgot to set C0 and C1 after line 5, that could be the problem. Muoshuu 580 — 9y
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? adark 5487 — 9y
View all comments (4 more)
0
yes, all of them are working yogipanda123 120 — 9y
1
@adark The exact reason why he mightn't be able to see an explosion. Muoshuu 580 — 9y
0
Ah, I see. adark 5487 — 9y
0
How do i fix it then? yogipanda123 120 — 9y

Locked by TheMyrco

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
2
Answered by
Invisum -5
9 years ago

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)

0
Thank you!!! I understand why it didn't work! yogipanda123 120 — 9y
1
Np, however I lost reputation :( Invisum -5 — 9y
Ad