Set GUI Visible not working for some reason

I’m trying to set a GUI visible to do a “countdown” in RunService.RenderStepped when DoCountdown becomes true. However, setting the Visible property does not show the GUI which is really confusing because I’ve had no problems with this property in the past.

Here’s the code:

RunService.RenderStepped:Connect(function(step)
	if DoCountdown then
		if not CountdownGui.Visible then CountdownGui.Visible = true end

		CurCountdownSec += step
		print("set gui visible"..tostring(CountdownGui.Visible))

		if math.floor(CurCountdownSec) == 0 then
			CountdownGui.TextLabel.Text = "3"
		elseif math.floor(CurCountdownSec) == 1 then
			CountdownGui.TextLabel.Text = "2"
		elseif math.floor(CurCountdownSec) == 2 then
			CountdownGui.TextLabel.Text = "1"
		end
		
		if CurCountdownSec > CountdownSec then
			local humanoid = Players.LocalPlayer.Character:FindFirstChild("Humanoid")
			humanoid:ChangeState(Enum.HumanoidStateType.Freefall)

			CountdownGui.Visible = false
			DoCountdown = false
			CurCountdownSec = 0
			HRP.Anchored = false
			--PortingBack = false
		end
	end
end)

I can see that print("set gui visible"..tostring(CountdownGui.Visible)) outputs true to the console but no GUI.

If I set the GUI Visible to true in the properties BEFORE running the game, I can see it just fine.

Likewise, the text labels do not update (when I manually set the GUI as visible before running).

Is it just not possible to set a GUI property like this in RunService.RenderStepped? Or maybe there is a better way to put countdown text on the screen? Or what am I missing?

Is this a server or a local script? If it’s a server script, maybe you are setting the GUI visible in ‘StarterGui’, not in PlayerGui.

you shouldn’t use render stepped for a countdown, instead set a property as the initial time, reduce it by 1 every second and update the gui by a property changed signal.
Can you also post where you define countdowngui

Instead of .Visible do .Enabled

RunService.RenderStepped:Connect(function(step)
	if DoCountdown then
		if not CountdownGui.Enabled then CountdownGui.Enabled = true end

		CurCountdownSec += step
		print("set gui visible"..tostring(CountdownGui.Visible))

		if math.floor(CurCountdownSec) == 0 then
			CountdownGui.TextLabel.Text = "3"
		elseif math.floor(CurCountdownSec) == 1 then
			CountdownGui.TextLabel.Text = "2"
		elseif math.floor(CurCountdownSec) == 2 then
			CountdownGui.TextLabel.Text = "1"
		end
		
		if CurCountdownSec > CountdownSec then
			local humanoid = Players.LocalPlayer.Character:FindFirstChild("Humanoid")
			humanoid:ChangeState(Enum.HumanoidStateType.Freefall)

			CountdownGui.Enabled = false
			DoCountdown = false
			CurCountdownSec = 0
			HRP.Anchored = false
			--PortingBack = false
		end
	end
end)