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

local meteor = Instance.new('Part', game.Workspace)
meteor.Name = 'Meteor'
meteor.Anchored = false

meteor.Touched:connect(function(part)
    if part.Name ~= 'BasePlate' then
        local boom = Instance.new('Explosion', game.Workspace)
        boom.Position = part.Position
        part:Destroy()
    end
end)

And this is the explosion script:

function onTouched(hit) 
if hit.Parent ~= nil then 
if (hit.Parent ~= game.Workspace) then 
e = Instance.new("Explosion") 
e.Parent = game.Workspace 
e.Position = hit.Position 
e.BlastRadius = 10 
e.BlastPressure = 1000000 
hit.Parent:BreakJoints() 
else 
e = Instance.new("Explosion") 
e.Parent = game.Workspace 
e.Position = hit.Position 
e.BlastRadius = 6 
e.BlastPressure = 1000000 
end 
end 
end 

script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
0
Answered by
yut640 91
7 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