I have a box that rotates when a button is clicked, I have 2 buttons, one on the ceiling and the other on the floor. Although the rotating works fine I noticed you can click on the other button and it could mess up the rotation. I inserted a boolean value and made this script but it doesn’t work, it did detect that it was false and I even did some debugging and it does change it to true but it does not do what I tell it to do.
if BoxDeb == false then
BoxDeb = true
print("rotating")
rotation:Play()
wait(2.5)
BoxDeb = false
print("done")
end
end)
if BoxDeb == true then
script.Parent:Destroy()
B.Brickcolor = BrickColor.new("Bright green")
end
if BoxDeb == false then
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = B
ClickDetector.MaxActivationDistance = 5
B.BrickColor = BrickColor.new("Brick yellow")
end