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.
✓ ANSWER ACCEPTED
Is it possible to print something if part touched another part?
1 answer
✓ Accepted answer
Yes, there is two ways I can think of for this to happen.
Option 1
local partA = game.Workspace.PartA
local partB = game.Workspace.PartB
local scriptA = script
local scriptB = game.Workspace.ScriptB
partA.Touched:Connect(function(part)
if part == partB then
scriptB.Disabled = true
end
end)
Option 2
local partA = game.Workspace.PartA
local partB = game.Workspace.PartB
local stopcode = false
partA.Touched:Connect(function(part)
if part == partB then
stopcode = true
end
end)
if stopcode == false then
-- code that could be stopped here
end
If this helped, please consider upvoting!
1 comment
0
Thank you.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You can try region3