Is it possible to get a model by using Explosion.Hit?

Hello, this is my first topic on the Developer Forums.

So i’m trying to create a health system using int value for a spaceship, so could I get a model by using Explosion.Hit? Or is it not possible and are there other alternatives to a health-system like this that I can try?

Sorry, I’m not too much of a good scripter.

Yes, it is very possible to get the model that a part belongs to through explosions. You can just check if the parent of the hit part is a model, then store that model as a variable.

Here’s an example of how to do it:

local explosion = Instance.new("Explosion")
--define the data of your explosion here

explosion.Hit:Connect(function(hit)
    local hitModel = nil
    if(hit.Parent:IsA("Model")) then
        hitModel = hit.Parent
        --do stuff with the model
    end
end)
3 Likes

Apparently the DevForum now has its own downloadable app

I believe you can use Hit.Parent to check if the Hit’s Parent is a model?

1 Like

So hitModel is the variable for the model the explosion is hitting. Got it, thank you