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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
Farsalis 369 Moderation Voter
4 years ago
Edited 4 years ago

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)

Ad
Log in to vote
0
Answered by
EmK530 143
4 years ago

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.

Answer this question