So the code runs perfectly until it goes into the if statement part (line 8 - end). The correct code and/or an explanation on what I did wrong would be highly appreciated.
Anchored = script.Parent.Anchored script.Parent.Touched:connect(function() script.Parent.BrickColor = BrickColor.new("Bright red") script.Parent.Anchored = false end) if Anchored == false then wait(3) Anchored = true script.Parent.BrickColor = BrickColor.new("Brown") script.Parent.Position = Vector3.new(-45, 18, -17.5) end
Anchored = script.Parent --Variable has to be the instance, not the property's value. script.Parent.Touched:connect(function() script.Parent.BrickColor = BrickColor.new("Bright red") Anchored.Anchored = false if Anchored.Anchored == false then --If statement inside of the function. wait(3) Anchored = true script.Parent.BrickColor = BrickColor.new("Brown") script.Parent.Position = Vector3.new(-45, 18, -17.5) end end)