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

Blow-up script?

How would i make a script when the player clicks a brick and the brick blows up and hurts the player? BOOM!

1 comment

0

I love the 'BOOM!' you added. Like we didn't know what blow up means you thought you might give us some more detail by adding its sound XD

2 answers

✓ Accepted answer
local part = script.Parent
local debounce = false

function boom(pos, pressure, radius, explosionType)
	local explosion = Instance.new("Explosion", game.Workspace)
	explosion.Position = pos
	explosion.BlastPressure = pressure
	explosion.BlastRadius = radius
	explosion.ExplosionType = explosionType or explosion.ExplosionType
end

part.ClickDetector.MouseClick:connect(function(player)
	if not debounce then
		debounce = true
		boom(part.Position, 250, 250)
		wait(2)
		debounce = false
	end
end)

1 comment

1

Thanks the script worked. :D

First of all, you need to make a ClickDetector inside of the brick. Put a script into that ClickDetector.

Put this in the script:

local Detect = script.Parent
local function onMouseClick()
	local Brick = CD.Parent
	local e = Instance.new("Explosion")
	e.Position = Brick.Position
	e.BlastPressure = 10000
	e.BlastRadius = 10 --Change this to the ClickDetector radius for best experience.
	e.ExplosionType = 0 --Does no terrain damage
	e.Parent = Brick
end
Detect.MouseClick:connect(onMouseClick)

Hope this helps ya!

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