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

How can a brick detect if it is touched by an Explosion?

Asked by 5 years ago

I tried having the code detect if it is being touched by something called "Explosion", but it doesn't work.

 health = script.Parent.Parent.Parent.Health
local debounce = false

function onHit(toucher)
if debounce == false then
    debounce = true
    if toucher.Name == "Explosion" then
    health.Value = health.Value - 10
    print (health.Value)
    wait(3)
    debounce = false
    script.Parent:Destroy()
    end
end
end
script.Parent.Touched:connect(onHit)

0
Try doing this, at line 7 : if toucher.Parent.Name == "Explosion" then, but im not quite sure AswormeDorijan111 531 — 5y
0
^^ No, the 'hit' (first returned arg) is the brick, it's not a kind of property in the part (the reason you see .Parent often is because a model can't be touched so to get the model (character or a player) you need to do .Parent User#20388 0 — 5y
0
If it's an actual Explosion instance, that instance has a Hit event which fires for every part the explosion 'touched'. RubenKan 3615 — 5y

Answer this question