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

Blow-up script?

Asked by 10 years ago

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

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 ConnorVIII 448 — 10y

2 answers

Log in to vote
2
Answered by
nate890 495 Moderation Voter
10 years ago
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
Thanks the script worked. :D masterhalo55 75 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

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!

Answer this question