Using an explosion as the event to trigger some code. Put it in a rough example showing the event listener please.
✓ ANSWER ACCEPTED
Explain to me the "Hit" event?
2 answers
✓ Accepted answer
local x=Instance.new("Explosion")
x.Hit:connect(function(hit)
hit.BrickColor=BrickColor.new("Really blue")
end)
x.Parent=workspace
Any part partially inside the BlastRadius will turn blue.
As any event, we use :connect() to connect a function to run when this event happens. This function is passed the arguments which are provided with the event.
According to the wiki, the Explosion.Hit event passes an Instance as first argument and a Number as second argument. The first argument is the part which is hit, the second is the distance from the explosion center to that part.
Example code: remove all red bricks when an explosion fires.
function FireExplosion(position)
local new = Instance.new("Explosion")
new.Hit:connect(function(part, distance)
if part and part.BrickColor == BrickColor.Red() then
part:Destroy()
end
end)
new.Position = position or Vector3.new()
new.Parent = game.Workspace
end
FireExplosion()
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Now it makes sense to me. I know how I'm going to do this...