Answered by
2 years ago Edited 2 years ago
Hello, cbeebiespoo!
Edit:
Apparently you are using each code on one part, so you dont want the click to toggle the value.
You just need to move the :Connect
to under the function
Disable:
1 | location = script.Parent.Parent.Parent |
2 | regen = script.Parent.Parent |
6 | script.Parent.Parent.IsOutOfOrder.Value = true |
9 | script.Parent.ClickDetector.MouseClick:Connect(onClicked) |
Enable:
1 | location = script.Parent.Parent.Parent |
2 | regen = script.Parent.Parent |
6 | script.Parent.Parent.IsOutOfOrder.Value = false |
9 | script.Parent.ClickDetector.MouseClick:Connect(onClicked) |
Old answer:
I found 3 problems in your code:
You are calling the :Connect
before defining the function, this can be easily fixed by moving the :Connect line to under the function definition
This doesn't really breaks your code, but may in the future. The :connect
has been deprecated, it is recommended to use :Connect
for new code.
The 2 scripts are reverting each other actions. You should use just one script to change the value, like so:
1 | location = script.Parent.Parent.Parent |
2 | regen = script.Parent.Parent |
6 | script.Parent.Parent.IsOutOfOrder.Value = not script.Parent.Parent.IsOutOfOrder.Value |
9 | script.Parent.ClickDetector.MouseClick:Connect(onClicked) |
If this solves your ploblem, please mark this answer as the "Accepted Answer"