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

How do I effect an anchored part if an explosion touches it?

Asked by 9 years ago

I'd like to make an anchored part react to an explosion. I've tried an onTouch script......

function T(hit)
    if hit.ClassName==("Explosion") then
script.Parent.Anchored=false    
    end
end
script.Parent.Touched:connect(T)

But I already pretty much knew that wouldn't work. Help is appreciated! :D

0
I edit my script, so now the baseplate won't fall down. EzraNehemiah_TF2 3552 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

There is an event called the Hit event. It fires when an explosion hits something.



The script is the event of the explosion, you could clone a script into the explosion as soon as it is created. The script should be:

script.Parent.Hit:connect(function(Part, PartDistance)
    if Part:IsA("BasePart") and Part.Anchored and not Part.Locked then
        Part.Anchored = false
    end
end)

Explosions don't use the Touched script like how parts do.


Parameters for Hit(Explosion):

  1. Part; Object Value The Part that gets hit by the explosion

  2. PartDistance; Float; The distance the part is from the explosion when the part got hit


Other stuff:

  • IsA sees what class the object belongs to

  • Anchored is when a part doesn't move




Hope this helps!

Ad

Answer this question