✓ Accepted answer
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:
location = script.Parent.Parent.Parent
regen = script.Parent.Parent
save = regen:clone()
function onClicked()
script.Parent.Parent.IsOutOfOrder.Value= true
end )
script.Parent.ClickDetector.MouseClick:Connect(onClicked)
Enable:
location = script.Parent.Parent.Parent
regen = script.Parent.Parent
save = regen:clone()
function onClicked()
script.Parent.Parent.IsOutOfOrder.Value= false
end )
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:
location = script.Parent.Parent.Parent
regen = script.Parent.Parent
save = regen:clone()
function onClicked()
script.Parent.Parent.IsOutOfOrder.Value= not script.Parent.Parent.IsOutOfOrder.Value
end )
script.Parent.ClickDetector.MouseClick:Connect(onClicked)
If this solves your ploblem, please mark this answer as the "Accepted Answer"
4 comments
Edit: Add codeblocks
Can I ask which line is that error on?
It wont say which line
the whole error says 15:28:50.511 attempt to call a nil value - Server