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

How can i do That if Certain Block touches another one, execute something?

My idea is to make like a Circuit pin, i want that when the + Pin of the LED touches the 5V part of the circuit which is none for now, and the -pin of the LED touches the GND part, make a pointlight activate

2 answers

✓ Accepted answer

It really depends what you want to do, and how you want to do it. Here are some examples:

--Example 1--

local Fivev = workspace['5v']
function Connect(part)
	if part:IsA("Part") and part.Name == "+Pin" then
		print(part.Name.." Has Connected To 5v!")
	end
end

Fivev.Touched:Connect(Connect)

--Example 2--

local GND = workspace.GND
function Connect(part)
	if part.StringValue.Value == "-Pin" and part:IsA("Part") then
		print(part.StringValue.Value.." Has Been Connected To GND!")
	end
end

GND.Touched:Connect(Connect)

You'd have to change something I make in this script as I don't know what your parts are named and where they are.

game.Workspace.Part1.Script

function touch(part)
	if part.Name == "Part2" then -- change part2 name to the part you're using!
		print("part1 is touching part2?") -- add some script in here instead of a print message
	end
end

script.Parent.Touched:Connect(touch)

Make sure there are no other parts with the name Part2 or whatever you've changed it to.

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