So I put a part in Workspace, then I put a NumberValue inside of the part.
I put this script in the NumberValue:
while true do if script.Parent.Value == 0 then print("It's zero") wait(5) end end
I did this hoping that when the NumberValue changed to 0 that it would print "It's Zero" but when i run the game i get the error "Game Script timeout".
Change the script to this:
1 | script.Parent:GetPropertyChangedSignal( 'Value' ):Connect( function () |
2 | if script.Parent.Value = = 0 then |
3 | print ( 'It\'s Zero' ) |
4 | end |
5 | end ) |
Now it will only run the code when the value is changed. Just be sure that when testing, go into server mode and edit the value there, or make a script to control that!