How can I make this elseif statement happen every time rather than once?

So I made this round script that makes a gui pop up every time the timer reaches 0 but it only makes the gui pop up once. Is there any way to solve this?

local roundlength = 15
local intermissionlength = 0
local InRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status
local Camera = workspace.CurrentCamera

	if InRound.Value == true then
		for _, playerCharacter in pairs(game.Players:GetChildren()) do
			local char = playerCharacter.Character
			char.HumanoidRootPart.CFrame = workspace.Spawns.LobbyTP.CFrame
	elseif InRound.Value == false then
		for _, player in pairs(game.Players:GetChildren()) do
			local playerGui = player:FindFirstChild("PlayerGui")
			if playerGui then
				local EndGui = playerGui.EndGui
				local GameInfo = EndGui.GameInfo
				local CameraHandler = EndGui.CameraHandler
				if GameInfo.Visible == false and CameraHandler.Disabled == true then
					GameInfo.Visible = true
					CameraHandler.Disabled = false

local function roundTimer()
	while wait() do
		for i = intermissionlength, 0, -1 do
			InRound.Value = false
			Status.Value = "TIME: ".. i ..""
		for i = roundlength, 0, -1 do
			InRound.Value = true
			wait (1)
			Status.Value = "TIME: ".. i ..""


why don’t you use loops instead?

I used while wait() do but that would give me the same result

Do you ever turn CameraHandler back on? It sounds like you permanently break this if statement the first time you call it. Feels like it is here.

I dont think you can detect player gui from server. You should’ve used local script with function, connected to remote event.

I dont know about remote events

Check out this article then, it should solve the issues.

I never get what the article is trying to explain, so thats why I did not use remote events. And the script does work, but only once

Script works only on server (Not sure about it. Did you checked output?) but never touches local side, most likely your gui pops up once because you put it into starterGui.

I did, but there were no errors. And the script goes on every PlayerGui. Not just one

Anyway, this script arent supossed to work with gui, here is article that can help you with understanding how remote events work and what they for.

I deleted that if statement and moved those lines to the previous one but same result

Have you tried using a while loop?

Yes, I used while wait() do. But it didnt fix the problem

You should try to use while true do

Ok I will open studio and try that now

1 Like

It would give me an error saying script timeout: exhausted allowed execution time

Ok put wait(2)
at the end of the while true do

while true do
--your code

It still gives me the same error

Can you show me the script you have