ScreenGui hiding during game play

I am working on a game and it is round based. I have a MainGui that says “Waiting for players” and then changes to "Get Ready’ and stays on that until the game is over, and then it shows who the winner is in place of “Get Ready”.

I also have another ScreenGUI that shows time left in the game and players left.

My question is how would one go about hiding the MainGui I described above during game play and only pop up when a winner is chosen and stay up till next round starts?

Here is the localscript I have in the MainGui:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local displayValues = ReplicatedStorage:WaitForChild("DisplayValues")
local status = displayValues:WaitForChild("Status")


local textLabel = script.Parent

local function updateText()
	textLabel.Text = status.Value
end

status.Changed:Connect(updateText)
updateText()

Here is my GameManager script located in ServerScriptService:

-- Services
local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")

-- Module Scripts
local moduleScripts = ServerStorage:WaitForChild("ModuleScripts")
local matchManager = require(moduleScripts:WaitForChild("MatchManager"))
local gameSettings = require(moduleScripts:WaitForChild("GameSettings"))
local displayManager = require(moduleScripts:WaitForChild("DisplayManager"))

-- Events
local events = ServerStorage:WaitForChild("Events")
local matchEnd = events:WaitForChild("MatchEnd")

while true do
	displayManager.updateStatus("Waiting for Players")

	repeat
		wait(gameSettings.intermissionDuration)
	until Players.NumPlayers >= gameSettings.minimumPlayers

	displayManager.updateStatus("Get ready!")
	wait(gameSettings.transitionTime)
	
	matchManager.prepareGame()
	local endState = matchEnd.Event:Wait()

	local endStatus = matchManager.getEndStatus(endState)
	displayManager.updateStatus(endStatus)

	matchManager.cleanupMatch()
	wait(gameSettings.transitionTime)

	matchManager.resetMatch()
end

I am still learning and decided to ask for any hints or tips for me to try.

1 Like

To hide a ScreenGui and all of its GuiObject descendants you simply need to set its “Enabled” property to false, take the following for example.

ScreenGui.Enabled = false

Doesn’t that hide it completely? I am trying to get it to only show at a certain time during the game.

Yes, then you’d re-enable that property when necessary (during that certain time as you mentioned).

script.Parent.StarterGUI.MainGui.Enabled = true

I inserted this into my code where I wanted the MainGui to activate and then added it where I wanted it to stop and changing it to false. All I got was it just turning off the Gui and showing the label instead. Did I use the wrong line for this?

Also I added that code in the GameManager script shown above.

Thank you for the time and help. I got it to work. I had an error in my code. I didn’t have it pointing to the StarteGui folder correctly.