Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

While Loop Using and Doesn't Start Looping?

Asked by 3 years ago
Edited 3 years ago
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.

0
What is subtracting the min.Value and sec.Value values? movementkeys 163 — 3y
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. movementkeys 163 — 3y
0
I subtract them in the while loop, but but does that matter RhysRocksRules 38 — 3y
0
Which while loop is the one not running? movementkeys 163 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

******ANSWER******

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

Thanks for helping anyways!

Ad

Answer this question