Trip Mine not working

Hello. So I’m trying to make a trip mine so that when a player steps on it it explodes and kills them.
That part of it works but I’m also trying to make it break parts that have both A. a folder named “Behaviors” inside it and B. a Bool Value named “Mineable” inside the folder. It explodes just fine but it’s not breaking the parts.

Here is my code:


script.Parent.Touched:Connect(function()
	
	local Explotion = Instance.new("Explosion", script.Parent)
	
	Explotion.ExplosionType = Enum.ExplosionType.NoCraters
	Explotion.Position = script.Parent.Position
	Explotion.BlastRadius = 6
	
	Explotion.Hit:Connect(function(hit)
		
		if hit.Parent:FindFirstChild("Behaviors") then
			if hit.Parent:FindFirstChild("Mineable") then
				hit.Parent:Destroy()
			end
		end
		
	end)
	
end)
2 Likes

I suggest adding something to check if the thing hit is a part and if it has a parent that isn’t workspace.
For example:

if hit.Parent:FindFirstChild(“Behaviors”) and hit.Parent ~= game.Workspace then
if hit.Parent:FIndFirstChild(“Mineable”) and hit:IsA(“Part”) then

1 Like

I tried that and still didn’t work. I’m sorry for the trouble.

Are you trying to break the parts of whoever stepped on it or break the parts of the trap line itself?

1 Like

I’m trying to make it where it both kills the player (That part works) and breaks every part around it with the Behavers folder and the Mineable Bool Value inside it.

Sorry it took me a while to respond, I got busy.

Here is an example of what I mean:

image

The Red circle is the trip mine.

And as you can see in the picture below, all of the blocks have this folder and bool value inside them, which is what the script it looking for.
image

Basically what I’m trying to do is have the trip mine break all of the blocks with that folder and bool value within a certain radios of the mine.

If you mean shatter by the word break, then it’s a no

1 Like

Try making the hit connection first then parenting it.

1 Like

Correct me if I’m wrong, but shouldn’t you be checking if this value is inside the folder and not just in the parent?

1 Like

How did I not see that?? I’m such an idiot. I’ll test that out as soon as I can. Thanks!

Hello. Just tested it. It works now! I’m such an idiot for not seeing that. Thank you so much for the help!

You’re not an idiot, I’ve made plenty of mistakes like that too. You’re welcome.

1 Like