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

My explosion isn't exploding?

Asked by 2 years ago

I don't understand what I'm doing wrong, I created a bomb that explodes and it works except for one thing. The explosion itself just doesn't work, it doesn't explode even though I destroyed it and set its position. Please do help.

local TimeF = math.random(1)
local Intermission = workspace.Elevator["Elevator Door"].OpenandClose.Intermission

wait(10)
Intermission.Changed:Connect(function()
    if Intermission.Value == 1 then
        script.parent.Floors.Value += 1
        if script.parent.Floors.Value == TimeF then
            local explosionPart = script.parent.base
            local explosion = Instance.new("Explosion",game.Workspace)
            explosion.Position = explosionPart.Position
            explosion.Visible = true
            explosion.DestroyJointRadiusPercent = 1
            explosion.BlastRadius = 4
            explosion.BlastPressure = 500000
            explosion:Destroy()
            script.parent.base.explode:Play()
            script.parent.base.Transparency = 1
            script.parent.Part.Transparency = 1
            script.parent.Part2.Transparency = 1
            wait(3.84)
            script.parent:Destroy()
        end
    end
end)

1 answer

Log in to vote
1
Answered by 2 years ago
Edited 2 years ago

Add a wait between the setting the explosion's values and the explosion:Destroy() you instantly destroy it after it happens, it has no time at all.

local TimeF = math.random(1)
local Intermission = workspace.Elevator["Elevator Door"].OpenandClose.Intermission

wait(10)
Intermission.Changed:Connect(function()
    if Intermission.Value == 1 then
        script.parent.Floors.Value += 1
        if script.parent.Floors.Value == TimeF then
            local explosionPart = script.parent.base
            local explosion = Instance.new("Explosion",game.Workspace)
            explosion.Position = explosionPart.Position
            explosion.Visible = true
            explosion.DestroyJointRadiusPercent = 1
            explosion.BlastRadius = 4
            explosion.BlastPressure = 500000
        wait(5)
            explosion:Destroy()
            script.parent.base.explode:Play()
            script.parent.base.Transparency = 1
            script.parent.Part.Transparency = 1
            script.parent.Part2.Transparency = 1
            wait(3.84)
            script.parent:Destroy()
        end
    end
end)

Ad

Answer this question