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

how would i make this part destroy on touched when the parent has a value inside of it?

im trying to make a part break from this touch function but i want to make it so that it will only break when the parent has a child inside of it called "break". this is the only way i know of doing it. any help?

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("break") then
		script.Parent:Destroy()
	end
end)

1 comment

0

wdym break?

1 answer

Your looking in the wrong area. hit is the part that touched your part. Your code should be this:

script.Parent.Touched:Connect(function(hit)
 	if script.Parent:FindFirstChild("break") then
  	      script.Parent:Destroy()
	end
end)

2 comments

0

no i want hit (part that touched the mainpart) to detect if the part has a child named "break" and if so then Destroy()

0

elaborate

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