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

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!

0
Thank you. iCROTony -1 — 5y
Ad

Answer this question