Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a brick detect when it touches another brick with a certain name?

Asked by 6 years ago

Do I make it check its children or its name?

2 answers

Log in to vote
0
Answered by 6 years ago

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)
Ad
Log in to vote
0
Answered by 6 years ago

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)

Answer this question