Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My explosion isn't exploding?

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

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.