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

Round timer isnt working/restarting?

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

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

1 comment

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

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