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

How to explode part on touch?

Asked by
micmnm4 18
7 years ago

How to explode part on touch?

1 answer

Log in to vote
1
Answered by 7 years ago

Insert a script into a part and inside the script type this:

local delayTime = 3 -- How long (in seconds) to wait after an explosion.
local currentlyDelaying = false -- Don't touch this.
script.Parent.Touched:connect(function(hit)
    if currentlyDelaying == false then
        local exp = Instance.new("Explosion", script.Parent)
        exp.BlastPressure = 500000 -- The pressure of the explosion
        exp.BlastRadius = 4 -- The radius of the explosion
        exp.DestroyJointRadiusPercent = 1 -- The radius of where joints are destroyed upon impact
        exp.ExplosionType = Enum.ExplosionType.Craters -- What type of explosion do you want? Craters, CratersAndDebris, or NoCraters.
        exp.Position = script.Parent.Position -- The position of the explosion
        exp.Visible = true -- If the explosion can be seen
        currentlyDelaying = true -- Sets currentlyDelaying to true so that the code will be ignored
        wait(delayTime) -- Waits the delay time.
        currentlyDelaying = false -- Sets currentlyDelaying to false so that the code will no longer be ignored.
    end
end)

This will create a nice powerful explosion on the part. Anyone who touches it will instantly be blown to bits!

Hope I helped! :)

Ad

Answer this question