Do I make it check its children or its name?
COMMUNITY QUESTION
How do I make a brick detect when it touches another brick with a certain name?
2 answers
You would need to use the touched function
It would work like this
script.Parent.Touched:connect(function(hit) --Activates when hit
if hit.Name == "the name" then --detects the name and runs the code
--code here
end
end)
Insert a script into the brick and type the following code into that script.
script.Parent.Touched:Connect(function(Object)
if Object:IsA('BasePart') then
if Object.Name == "PART NAME HERE" then
print(Object.Name .. ' has touched ' .. script.Parent.Name .. '.')
-- This is where you would add the rest of your code. --
end
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
