Explosions Detection help

Hi there!

I’m currently designing a tank system which is working pretty well. I was wondering whether there was a way to detect when a model is affected by an explosion. For example: https://youtu.be/MDWGsAwgId8

I’ve tried the following

Tank.DescendantRemoving:Connect(function(Part)
     if Part:IsA("Weld") then
         print("Tank was blown up!");
     end
end)

to no avail.

Any help would be appreciated,
Thanks, -Tom :slight_smile:

1 Like

you could do a ChildAdded function calling with the child as an argument, and check to see if the child’s ClassName is an explosion.

Tank.ChildAdded:Connect(function(child)
 if child.ClassName == "Explosion" then
     print("Tank was blown up!");
 end
 end)

The explosion is independent of the tank, the explosion itself is parented to a folder called “Explosions” directly inside the workspace and no explosions are instantiated inside the model so this doesn’t work (I did try it).

Oh… in that case, please explain how your system works because you did not explain it in your post.

The system works by the missile coming into contact with something (parts of the tank that fired it are ignored), it then instantiates an explosion object inside a folder called “Explosions” and the position of the explosion is set to the position of the missile when contact was made. As you can see in the video, the explosion has an effect on the tank if the tank is too close, I was wondering whether there was a way to detect this interaction with a script.

You can use the class Explosion in roblox to create the explosions if you’re not already (you can make it not damage iirc.)
And then you can use the event Explosion.Hit like this :

local explosion = Instance.new("Explosion")
explosion.Hit:Connect(function(hit,distance)
   print("Part hit:",hit,"at distance:",distance)
end)

EDIT : For some reason devforum showed me that my message wasn’t sent but it was sent at the same time? sorry.

Thanks! I wasn’t aware the explosion object had a collision event like regular BaseParts do. Yeah, I am using standard Roblox Explosion objects because why bother with the hassle of creating your own explosion :stuck_out_tongue:
(I think the DevForum timed out while you were typing because my reply also didn’t send while you were typing yours)

1 Like