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 detect if a part touches anything that is also a part.?

I'm trying to figure this out but I have no idea how to do it.

3 answers

If you wanted to make sure that the other part is a part, then you would use the IsA() function with a Touched event.

game.Workspace.Part.Touched:connect(function(part) --Touched event
	if part:IsA("Part") then --IsA() function
		--code
	end
end)

Or, if you wanted the touching part to be another type of part, like a MeshPart, or WedgePart, you would check if it is a BasePart.

game.Workspace.Part.Touched:connect(function(part) --Touched event
	if part:IsA("BasePart") then --IsA() function
		--code
	end
end)

Good luck!

If this helps, please be sure to accept my answer as this benefits the both of us.

You would first create the function -- Workspace.Part.Touched:connect(function(otherPart) then you would check if the other part is named what you'd like it to be named, it could be object, or anything---- if otherPart.ClassName = "Example" then after this, you'd insert your code. You could do this with a player, but you'd need to check for the humanoid.

If this helped, make sure to accept answer!

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