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)

3 comments

0

Try doing this, at line 7 : if toucher.Parent.Name == "Explosion" then, but im not quite sure

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

0

If it's an actual Explosion instance, that instance has a Hit event which fires for every part the explosion 'touched'.