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

if Part1 touch Part2?

Hello. I want to make that a Block with the name "Part1" detect if a Block with the name "Part2" touch the Block(with the name "Part1"). How it works?

1 comment

0

game.Workspace.Part1.Touched:connect(function(part) if part.Name == 'Part2' then --[[Code]] end end)

1 answer

Part.Touched

Touched allows you to fire a function when one part touches another.

How do I do it?

Check if the Part it touched is called Part2

local Part1 = workspace.Part1;
Part1.Touched:connect(function(hit)
	if hit.Name == "Part2" then
		-- Touched!
		print("Touched")
	end
end)

This checks if a Part in Workspace touched a Part called Part2 and prints Touched if it did

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