Script is disabled, but still works

This script is supposed to increase the value of a NumberValue every one second, however, when I disable it, the value continues to rise. Please help!

while true do
	script.Parent.Temperature.Value = script.Parent.Temperature.Value + 1

It is disabled by a line of code from a different script.

core.Heater.Disabled = true

Check to make sure the line of code is firing, and ensure you are referencing the correct script. The script should disable and value should stop rising.

I checked.
If I destroy the script, the value stops rising. However, when I disable it, it continues to rise.
It’s being referenced right, and the code is firing.

Make sure you do not have any other script that’s got something to do with that specific value rising.

Yeah, I checked that as well. If I had those running, if I destroyed the script, the temperature would still rise. It only rises if I disable it. On destruction, rising stops.

So have you found your issue or are you still having the same problem?

Same problem. I may have to consider cloning the script or something, but this is very odd.

So you are just trying to disable rising entirely, back at where you said it only rises if I disable it you could try do the opposite of it.

True, but that’s an extra script, and adds unnecessary complications.

Alright, I fixed it.

I had to put a check in the while true do function to only run if the script wasn’t disabled. This seems to have fixed it. Thanks for the help everyone :grinning_face_with_smiling_eyes: .

I can’t think of anything else that could be causing this, but you could make your code more efficient by using either a bindable event or a .Changed event from a bool value to stop the heater.

See, the script already compiled, hence why it’s running.

I just realised is the core.Heater.Disabled = true in the loop?

Maybe you can try this:

script.Parent.Temperature.Value = script.Parent.Temperature.Value + 1
script.Disabled == true

(btw im pretty sure loops of any kind in a disabled script will still run even if the script is disabled.)

1 Like

Try putting core.Heater.Disabled = true in the loop. I believe if you do then it would always be checking if its disabled.

Solution has been marked everyone, no need to add any more answers. Thank you.