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

Round timer isnt working/restarting?

Asked by 3 years ago
Edited 3 years ago
local repstore = game:GetService("ReplicatedStorage")
local playercount = repstore.playercount
local status = repstore.status
local inRound = repstore.inRound
local vote = repstore.vote
local time = 10

local players = game:GetService("Players")

local function playerCounter()
    wait()
    if players.PlayerAdded then
        playercount.Value = playercount.Value + 1
    elseif players.PlayerRemoving then
        playercount.Value = playercount.Value - 1

    end
end
playerCounter() -- ignore this playercounter, I will be using it later on.

local function timer()
    for i = time, 1, -1 do
        wait(1)
        status.Value = "Intermission: " .. i .. " Seconds Left"
    end
    wait()
    inRound.Value = true
end

--start
if inRound.Value == false then 
        timer()
    end
    if inRound.Value == true then
        return
    end
--  end : im using this section just for the initial start of the game, ill be using my playercounter 
-- later on; like 2 people are needed to start, etc.

inRound:GetPropertyChangedSignal("Value"):Connect(function() 
    while wait() do
    if inRound.Value == false then
        timer()
        end
    if inRound.Value == true then
            return
        end
    end
end) -- here is where i tried to repeat the timer but it just doesnt work


Any help is appreciated, thanks! EDIT: The error is that the status doesnt restart, so the "Intermission i Seconds Left" doesn't show again after the first time i called it.

1 answer

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

When answering, if your answer does not fully solve the question, it should be written as a comment to the question instead of as an answer.

I think return stops the while wait() do loop and exits out of the function.

0
yeah i thought that was it as well but it still didn't update the status. I tried to do a print statement whenever the inRound value changed but that also didn't work vNLegacy 9 — 3y
Ad

Answer this question