So I was able to make four nails that can each be unscrewed with a click and I want them to unanchor a union when I unscrew all the nails, so I used this code in the union below:
while true do if game.Workspace.Nail1.Anchored = false then if game.Workspace.Nail2.Anchored = false then if game.Workspace.Nail3.Anchored = false then if game.Workspace.Nail4.Anchored = false then script.Parent.Anchored = false end end end end end
The problem is that the script doesn't work because it has the red underline under the first equal sign, and I don't know how to fix it. WHY?!?!
There are a few things that can be fixed here.
First of all, when doing if then statements, it requires a double equal (==) sign. Secondly, you can condense this into one if then statement. Lastly, make sure to add a delay in the while true do, so you don't kill your studio when running.
while true do wait() if not game.Workspace.Nail1.Anchored and not game.Workspace.Nail2.Anchored and not game.Workspace.Nail3.Anchored and not game.Workspace.Nail4.Anchored then then script.Parent.Anchored = false end end
Hope I helped!
while true do function onClicked(ObjectName) game.Workspace.ObjectName.Anchored = false then game.Workspace.Nail1.Anchored = false game.Workspace.Nail2.Anchored = false game.Workspace.Nail3.Anchored = false game.Workspace.Nail4.Anchored = false script.Parent.Anchored = false end end end end end game.Workspace.ObjectName.ClickDetector:connect(onClicked)
try that sorry I had no time to go on studio mode!
warning: name ObjectName the objects name
Hope this helped enjoy!