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

How to make the script only execute when specific brick collides with other?

So uhm, I'm having a big problemo and I was wondering how can I make the script only execute when the specific block is touched for example, if brick "center" from a Vehicle touches the brick that has the touchinterest line.

function onTouched(hit)
if debounce == false then
	debounce = true
	check = hit.Parent.Trucks1:FindFirstChild("Center") --this is where I get confused
	print ("Found TruckCenter")

	if check ~= nil then 

1 answer

Assuming you have your script in a part

local part = script.Parent

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild('Trucks1'):FindFirstChild('Center') then
		-- Found it!
	end
end)

You can also test the name but I just copied what you writed on line 4 (I added findfirstchild on trucks though as it might not exist)

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