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 10 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

01function onTouched(hit)
02local weld = Instance.new ("Weld")
03weld.Parent = hit
04weld.Part0 = script.Parent
05weld.Part1 = hit
06wait(5)
07--not my part
08ex = Instance.new("Explosion")--Create An Explosion
09ex.Position = script.Parent.Position --The Explosions Position Is The Brick
10ex.BlastRadius = 2 --A 5 by 5 Explosion.
11ex.Parent = script.Parent --You got to be able to see it.
12--my part again
13hit:BreakJoints()
14script.Parent:Remove()
15 
16end
17 
18connection = 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 — 10y
0
no that is the problem! yogipanda123 120 — 10y
0
You forgot to set C0 and C1 after line 5, that could be the problem. Muoshuu 580 — 10y
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 — 10y
View all comments (4 more)
0
yes, all of them are working yogipanda123 120 — 10y
1
@adark The exact reason why he mightn't be able to see an explosion. Muoshuu 580 — 10y
0
Ah, I see. adark 5487 — 10y
0
How do i fix it then? yogipanda123 120 — 10y

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
10 years ago

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

01function onTouched(hit)
02    local weld = Instance.new ("Weld")
03    weld.Parent = hit
04    weld.Part0 = script.Parent
05    weld.Part1 = hit
06    wait(5)
07    local explo = Instance.new("Explosion")
08    explo.Parent = game.Workspace
09    explo.BlastRadius = 2
10    explo.Position = Vector3.new(script.Parent.Position.X,script.Parent.Position.Y,script.Parent.Position.Z)
11    hit:BreakJoints()
12    wait(1)
13    script.Parent:Remove()
14end
15 
16connection = script.Parent.Touched:connect(onTouched)
0
Thank you!!! I understand why it didn't work! yogipanda123 120 — 10y
1
Np, however I lost reputation :( Invisum -5 — 10y
Ad