Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script is not detecting NumberValue change ? Game Script Timeout?

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".

1 answer

Change the script to this:

script.Parent:GetPropertyChangedSignal('Value'):Connect(function()
	if script.Parent.Value == 0 then
		print('It\'s Zero')
	end
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!

This discussion is preserved as it was. New answers, comments, and votes are closed.