Answered by
4 years ago Edited 4 years ago
Just a few things to point out...
1 | local isPressed = workspace.Bools.isButtonClicked |
This variable isPressed
has been set to the BoolValue instance and NOT the actual value that the boolean instance may be.
To get the value of the boolean it would be this...
1 | local isPressed = workspace.Bools.isButtonClicked.Value |
This will mean that isPressed
is either true or false now. What you had before meant that isPressed
was always true, because the BoolValue instance existed and that's enough to pass as true.
Your script should look a little more something like this...
2 | local isPressed = workspace.Bools.isButtonClicked |
4 | if isPressed and isPressed.Value then |
5 | script.Parent:Destroy() |
I took the initiative to have this loop only run once a second. Depending on your situation you may not need an instantaneous response and a maximum second response may suffice. Just be sparing when it comes to using loops with wait()
. Using a few is fine, but eventually they'll all add up! The additional return
line is to break the loop so that after the instance is destroyed you're not forever still checking if the button was clicked.