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

While Loop Using and Doesn't Start Looping?

local RepStorage = game:GetService("ReplicatedStorage");
local TimerValues = RepStorage:WaitForChild("Timer");
local min = TimerValues:WaitForChild("Min");
local sec = TimerValues:WaitForChild("Sec");
local StateOfGame = game:GetService("ServerStorage"):WaitForChild("StateOfGame");

function start_timer(minutes, seconds)
	min.Value = minutes;
	sec.Value = seconds;
	
	--For debugging
	print(min.Value);
	print(sec.Value);
	
	while min.Value == 0 and sec.Value == 0 do
		--blah blah blah
	end
end

while (true) do
	wait(5);
	if StateOfGame.Value == "Intermission" then
		start_timer(0, 30);
		
		repeat
			--print(tostring(min.Value).." and "..tostring(sec.Value));
			wait();
		until min.Value == 0 and sec.Value == 0;

		StateOfGame.Value = "Start";
		
	end
	wait()
end

When debugging and going line-by-line, it doesn't go into the loop even though min.Value == 0 and sec.Value == 30, what am I doing wrong?

This is a server script inside of ServerScriptService

Ask for more information if you need it, and thanks in advance.

4 comments

0

What is subtracting the min.Value and sec.Value values?

0

Putting this in a seperate comment because its a different topic, but there is a far easier way to go about this. Look up Tick() on the wiki. it will remove the need for all of this code I'm pretty sure.

0

I subtract them in the while loop, but but does that matter

0

Which while loop is the one not running?

1 answer

ANSWER

I figured it out myself, it was a simple fix, I accidentally said == instead of ~=.

Thanks for helping anyways!

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