Hello. I'm trying to make a script that runs one thing if it's touching an object, and run another script if it isn't. Say A is the object I want to touch object B. I'm trying to make it so that when a button is clicked, if A is touching B, then run script 1. If A isn't touching B, run script 2. The current script i'm using is
script.Parent.ClickDetector.mouseClick:connect(function()
if Workspace.Part.Touched:connect(function() then
script.Parent.Parent.A.AlignOrientation.Enabled = true
script.Parent.Parent.A.AlignPosition.Enabled = true
wait(2)
script.Parent.Parent.A.AlignOrientation.Enabled = false
script.Parent.Parent.A.AlignPosition.Enabled = false
end)
else
script.Parent.Parent.A.AlignOrientation.Enabled = false
script.Parent.Parent.A.AlignPosition.Enabled = false
wait(2)
script.Parent.Parent.A.AlignOrientation.Enabled = true
script.Parent.Parent.A.AlignPosition.Enabled = true
end)
It doesn't do anything when clicked, so any help fixing this would be appreciated. Thanks!

2 comments
I'm still a bit new at scripting, so how would you do that? Do you have any videos or forum links that can teach it?
I'll give you an example.