I need help with making an Explotion

Hi, I’m new to scripting, so I don’t understand many things. I’m trying to make an explosion that includes smoke and sound that happens at a random time in between 10 to 30 seconds. I’ve looked at other scripts for help, but I couldn’t figure it out!
Workspace:


My script:

Dust = script.Parent.Smoke
Howlong = script.Parent["Value"].Value


while true do
Dust = false
Howlong = math.random(10,30)
script.Parent.FIRE:Play()
wait(4)
Ex = Instance.new("Explosion")
Dust = true
Ex.BlastPressure = 5000
Ex.BlastPressure = 4
Ex.Position = script.Parent.Position
wait(3)
Dust = false
end



1 Like

Explosion is not parented in Workspace, try to parent it!

Ex.Parent = workspace

And tell me if that works or not :slight_smile:

The parenting made the explosion work, so thank you for that!
But some things are still not working as wanted, such as:
Explosions are happening at a constant pace, not random
No smoke.

the updated script:

Dust = script.Parent.Smoke
Howlong = script.Parent["Value"].Value


while true do
Dust = false
Howlong = math.random(10,30)
script.Parent.FIRE:Play()
wait(4)
Ex = Instance.new("Explosion")
Dust = true
Ex.BlastPressure = 5000
Ex.BlastPressure = 4
Ex.Position = script.Parent.Position
Ex.Parent = workspace
wait(3)
Dust = false
end




Also I should mention that the

wait(4)

Is meant for the sound

You forgot to write Enabled in Dust:

Dust.Enabled = true
--//Instead of
Dust = true

And what do you mean with “Not random”??

Instead of

script.Parent.FIRE:Play()
wait(4)
Ex = Instance.new("Explosion")
Dust = true
Ex.BlastPressure = 5000
Ex.BlastPressure = 4
Ex.Position = script.Parent.Position
Ex.Parent = workspace
wait(3)
Dust = false

You should change the position of some lines:

Ex = Instance.new("Explosion")
Dust = true
Ex.BlastPressure = 5000
Ex.BlastPressure = 4
Ex.Position = script.Parent.Position
Ex.Parent = workspace
wait(3)
Dust = false
wait(4)
script.Parent.FIRE:Play()

Ok I will add Enabled
When I said “Random” what I meant to say is anywhere in-between of 10 to 30 seconds
Also, the sound includes the firing of the cannon and the actual explosion, which I should have said. So I want to play the sound then wait for the explosion.
Sound: https://www.roblox.com/library/3850233766/Shot

Thank you!

To use random with wait(), write this:

--The line that set Howlong
wait(Howlong)

That line will wait the selected number of Howlong.

1 Like

Thanks for all your tips, it really help a lot! Just to make sure, here is my script:

Dust = script.Parent.Smoke
Howlong = math.random(15, 30)

while true do
Dust.Enabled = false
wait(Howlong)
script.Parent.FIRE:Play()
wait(4)
Ex = Instance.new("Explosion")
Dust.Enabled = true
Ex.BlastPressure = 5000
Ex.BlastRadius = 15
Ex.Position = script.Parent.Position
Ex.Parent = workspace
wait(3)
Dust.Enabled = false
end

I think that should work! Also, if that helped, make sure to mark my post as Solution!