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

Is it possible to print something if part touched another part?

Asked by 5 years ago

I want to do a code that will stop another code when one part touches another part. Is there a way to do that? Please help me.

0
You can try region3 UltraUnitMode 419 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

Yes, there is two ways I can think of for this to happen.

Option 1

1local partA = game.Workspace.PartA
2local partB = game.Workspace.PartB
3local scriptA = script
4local scriptB = game.Workspace.ScriptB
5partA.Touched:Connect(function(part)
6    if part == partB then
7        scriptB.Disabled = true
8    end
9end)

Option 2

01local partA = game.Workspace.PartA
02local partB = game.Workspace.PartB
03local stopcode = false
04 
05partA.Touched:Connect(function(part)
06    if part == partB then
07        stopcode = true
08    end
09end)
10 
11if stopcode == false then
12    -- code that could be stopped here
13end

If this helped, please consider upvoting!

0
Thank you. iCROTony -1 — 5y
Ad

Answer this question