As you read from the title, I wanna know how do I check if an object touched another..
How can I check if an object touched another object?
1 answer
First you need to define your object you want to be touched. So say the script is inside of said object.
script.Parent
Now you need the Touched function.
script.Parent.Touched:Connect(function()
end)
Now to answer your specific part of the quest you get the touching object for the touched part by adding a variable inside the function parenthesis.
script.Parent.Touched:Connect(function(Hit)
end)
That would be where I put "Hit" inside the script. You can change that to anything but that's what I prefer. Then to see if it's touched by a specific object you make an if statement basically asking that same question.
script.Parent.Touched:Connect(function(Hit)
if Hit and if Hit == game.Workspace.Baseplate or Hit.Parent == game.Workspace.Baseplate then
print("Your desired object touched this object")
end
end)
In that script if the brick the script is inside of hits something named baseplate or the parent of what it hits is named baseplate then it will print Your desired object touched this object"
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
Also if anyone says I need to indent I say no. I am an avid hater of indenting, I find it makes your code look like sloppy pinetrees and I will not stand for it.
You can be a hater of indenting as much as you want, but your code looks sloppy without it. Might as well write a paragraph about the mundane process of paint drying. Indentations also help others understand the code better and also makes editing a lot easier. Without the code indentations, it looks like you wrote a research paper about the complicated process of teleportation.
IT worked... Had to make a bit of fixing... but thanks!
enjoy your pinetree of ends then.