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

Script keeps ignoring the reset of value, how to fix?

The script keeps subtracting 1 from the value like it's supposed to do, although it keeps going into the negatives and not resetting it back to 59.

local seconds = script.Parent.RoundSeconds
local minutes = script.Parent.RoundMinutes

while true do
	wait(1)
	script.Parent.RoundSeconds.Value = script.Parent.RoundSeconds.Value - 1 --still does this
	if script.Parent.RoundSeconds.Value == 0 then
		wait(1)
		script.Parent.RoundSeconds.Value = 59 --its skipping this
		minutes.Value = minutes.Value - 1
		print("should've made it be the thing that im looking for aaaaaaaaaaaaaaaa") 
	end
end

1 answer

✓ Accepted answer

I don't exactly know what the problem is but you aren't really making use of the variables you declared properly and also you are ignoring the power of condition statement in the while loop.

Since I am guessing you are trying to make something like a round base stuff, I wrote a small simple code for that.

local seconds = workspace.seconds; -- IntValue Object in workspace
local minutes = workspace.minutes; -- same as above

local MAX_VALUE = 59;

seconds.Value = MAX_VALUE;
minutes.Value = 2; -- intermission minutes

while (minutes.Value > 0) do
	seconds.Value = seconds.Value - 1;
	
	if (seconds.Value < 0) then
		seconds.Value = MAX_VALUE;
		minutes.Value = minutes.Value - 1;
	end
	
	wait(1);
	print("Second: " .. seconds.Value);
	print("Minute: " .. minutes.Value);
end

Make use of while loop properly.

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