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.
Yes, there is two ways I can think of for this to happen.
Option 1
1 | local partA = game.Workspace.PartA |
2 | local partB = game.Workspace.PartB |
3 | local scriptA = script |
4 | local scriptB = game.Workspace.ScriptB |
5 | partA.Touched:Connect( function (part) |
6 | if part = = partB then |
7 | scriptB.Disabled = true |
8 | end |
9 | end ) |
Option 2
01 | local partA = game.Workspace.PartA |
02 | local partB = game.Workspace.PartB |
03 | local stopcode = false |
04 |
05 | partA.Touched:Connect( function (part) |
06 | if part = = partB then |
07 | stopcode = true |
08 | end |
09 | end ) |
10 |
11 | if stopcode = = false then |
12 | -- code that could be stopped here |
13 | end |
If this helped, please consider upvoting!