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

Meteor script that destroys other parts it touches is not working, help?

Asked by 8 years ago

So i have gotten help to fix this, and it has gotten better but theres still problems with it. When i hit run to test it, the baseplate has an explosion in the middle of it and gets destroyed even though the Meteor didn't touch it, and also when the Meteor falls onto a part i added in for testing, the explosion gets created in the middle of the part, and also does not get destroyed. I have a separate explosion script from the one i need help with, but i don't know if thats the problem because the explosion does not happened wherever it hit on the part but in the middle of it.

So this is the script for the parts it touches to get destroyed:

01local meteor = Instance.new('Part', game.Workspace)
02meteor.Name = 'Meteor'
03meteor.Anchored = false
04 
05meteor.Touched:connect(function(part)
06    if part.Name ~= 'BasePlate' then
07        local boom = Instance.new('Explosion', game.Workspace)
08        boom.Position = part.Position
09        part:Destroy()
10    end
11end)

And this is the explosion script:

01function onTouched(hit)
02if hit.Parent ~= nil then
03if (hit.Parent ~= game.Workspace) then
04e = Instance.new("Explosion")
05e.Parent = game.Workspace
06e.Position = hit.Position
07e.BlastRadius = 10
08e.BlastPressure = 1000000
09hit.Parent:BreakJoints()
10else
11e = Instance.new("Explosion")
12e.Parent = game.Workspace
13e.Position = hit.Position
14e.BlastRadius = 6
15e.BlastPressure = 1000000
16end
17end
18end
19 
20script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
0
Answered by
yut640 91
8 years ago

I just tested the script and it is working. All I did was copy paste the code into 2 scripts in the workspace. Both scripts are named script. Made them both separate, non grouped scripts. Maybe it's an error with your set up? This script is working fine for me. Meteor hits a part, explosion is created in center of part, part gets removed. Not sure what the issue could be for you.

Ad

Answer this question