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

How do I make a part disappear after being hit by an explosion?

Asked by 6 years ago

Hello, I've been trying to figure out how to do this for a while for my new game. So far I've come up with

script.Parent.ChildAdded:connect(function(instance) print(instance.Name .. " added to the workspace") end) Instance.new("Part", script.Parent) --> Part added to the Workspace

this means when my part experiences body force, it prints "added to the workspace". I just need help on making Cancollide = false. Thank you.

1 answer

Log in to vote
0
Answered by 6 years ago

If you wish you want to detect when a part is hit by an explosion, do this:

-- define explosion
explosion.Hit:Connect(function(part, distance) -- part is the part that is hit by the explosion, and distance is how far away the part is from the explosion
    -- code goes here
end)

If you wish to simply make any part hit by the explosion disappear, use this:

-- define explosion
explosion.BlastPressure = math.huge -- Make it so that the explosion applies an infinite amount of force to any parts caught in the blast radius.
0
What do I define the explosion as? nickos3 4 — 6y
0
Well... an explosion. e.g. Instance.new("Explosion"). Whichever explosion your using works, just use the same variable sweetkid01 176 — 6y
0
2 more questions (sorry, I'm a beginner scripter) do you put the script on top in the explosion part or the part that you want to disappear? And, what do you write for "code goes here"? nickos3 4 — 6y
0
It goes for the explosion. Also, "code goes here" is the code for when the part gets hit, like the non-CanCollide stuff sweetkid01 176 — 6y
0
The use of `explosion.Hit` is correct, however the use of `explosion.BlastPressure` to get rid of parts is not. Don't do that. Call `:Destroy()` on the part instead. Alternatively you could use `Debris:AddItem()` to ask Roblox to destroy it later. Link150 1355 — 6y
Ad

Answer this question