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?