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
01 | function onTouched(hit) |
02 | local weld = Instance.new ( "Weld" ) |
03 | weld.Parent = hit |
04 | weld.Part 0 = script.Parent |
05 | weld.Part 1 = hit |
06 | wait( 5 ) |
07 | --not my part |
08 | ex = Instance.new( "Explosion" ) --Create An Explosion |
09 | ex.Position = script.Parent.Position --The Explosions Position Is The Brick |
10 | ex.BlastRadius = 2 --A 5 by 5 Explosion. |
11 | ex.Parent = script.Parent --You got to be able to see it. |
12 | --my part again |
13 | hit:BreakJoints() |
14 | script.Parent:Remove() |
15 |
16 | end |
17 |
18 | connection = script.Parent.Touched:connect(onTouched) |
Please help!!! Thank you!!! --this is in a regular script, should it be in local?
Here is the right script. It works and you can see the explosion
01 | function onTouched(hit) |
02 | local weld = Instance.new ( "Weld" ) |
03 | weld.Parent = hit |
04 | weld.Part 0 = script.Parent |
05 | weld.Part 1 = hit |
06 | wait( 5 ) |
07 | local explo = Instance.new( "Explosion" ) |
08 | explo.Parent = game.Workspace |
09 | explo.BlastRadius = 2 |
10 | explo.Position = Vector 3. new(script.Parent.Position.X,script.Parent.Position.Y,script.Parent.Position.Z) |
11 | hit:BreakJoints() |
12 | wait( 1 ) |
13 | script.Parent:Remove() |
14 | end |
15 |
16 | connection = script.Parent.Touched:connect(onTouched) |
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?