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

How do I get my code to repeat explosions?

I used a piece of code from another question here so I could make explosive bricks, but I modified it and cant seem to get it to constantly repeat explosions.

local currentlyDelaying = false -- Don't touch this.
	if currentlyDelaying == false then
		repeat
	        local exp = Instance.new("Explosion", script.Parent)
	        exp.BlastPressure = 750000 -- The pressure of the explosion
	        exp.BlastRadius = 5 -- The radius of the explosion
	        exp.DestroyJointRadiusPercent = 400 -- 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 = false -- If the explosion can be seen
			wait(0.1)
until		wait(10)
		script.Parent:Destroy()
	end

2 comments

0

instead of repeat, put while true do.

0

but then how would i make the until still work?

2 answers

✓ Accepted answer
local currentlyDelaying = false -- Don't touch this.
if currentlyDelaying == false then
	local stopLoop = false
	spawn(function()-- spawn is basically running two scripts at once
		wait(10)
		stopLoop = true -- waiting for 10 seconds and then the loop stops
	end)
	while true do
		local exp = Instance.new("Explosion", script.Parent)
		exp.BlastPressure = 750000 -- The pressure of the explosion
		exp.BlastRadius = 5 -- The radius of the explosion
		exp.DestroyJointRadiusPercent = 400
		exp.ExplosionType = Enum.ExplosionType.Craters
		exp.Position = script.Parent.Position 
		exp.Visible = false
		if stopLoop == true then
			break -- breaks out of loop if stop loop is true
		end
		wait(0.1)
	end
	script.Parent:Destroy()
end

1 comment

0

Thank you so much!

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