Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

1 comment

0

I edit my script, so now the baseplate won't fall down.

1 answer

✓ Accepted answer

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.