Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

1 comment

0

You can try region3

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.