How would you make something that, when clicked, checks if one brick is touching another brick, then does what the script says? Would it be like,
script.Parent.ClickDetector.mouseClick:connect(function() if function onTouched(hit) then --script else -- script end) script.Parent.Touched:connect(onTouched)
I want the onTouched(hit) to be, if object 1 is touching object 2, then run the script. If object 1 isn't touching object 2, then run a different script. Any help would be appreciated.
I'm currently using the script
script.Parent.ClickDetector.mouseClick:connect(function() script.Parent.Parent.B3.AlignPosition.Enabled = false wait(.5) script.Parent.Parent.B3.AlignPosition.Enabled = true wait(.5) script.Parent.Parent.B3.AlignPosition.Enabled = false wait(.5) script.Parent.Parent.B3.AlignPosition.Enabled = true wait(.5) script.Parent.Parent.B3.AlignPosition.Enabled = false end)
B3 being the object that is moving.
This is as far as I can help as your "objects" and "scripts" you want are unknown... Hope this is helpful.
local clicked = false script.Parent.ClickDetector.mouseClick:connect(function() if clicked == false then clicked = true else return end end) script.Parent.Touched:connect(function(hit) if clicked == true then if hit.Parent == nil then return end if hit then if hit.Parent == Object1 then ---SCRIPT else if hit.Parent == Object2 then ---SCRIPT end end end end end)