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

Why NumberValue does not reset once it hits 0? Just goes into negatives

Like the most basic thing and i'm having a problem with it. It's just a count down thing. Two number Values and once the seconds hit 0 its supposed to go back to 60 and drop a minute. But the timer just keeps counting down into the negatives.

local min = script.Minutes
local sec = script.Seconds
local night = script.Night

while true do
	wait(1)
	sec.Value = sec.Value - 1
end

sec.Changed:connect(function()
	if sec == 0 then
		sec.Value = 60
		min.Value = min.Value - 1
	end
end)

Any help is appreciated!

Edit: Sorry I worded the title terribly. I just could not think of a way to ask this.

1 answer

✓ Accepted answer

On line 11, you check if the value instance is equal to 0, when you should be checking if the value’s value is equal to 0.

if sec.Value == 0 then

instead of

if sec == 0 then

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