Skip to main content

GameState

GameState holds the states of the game's startup and front-end flow, from launching to playing in the world. Use it to tell whether the world is loaded.

Available on: Client

Values​

GameState​

Used by Game.GetState() (client): returns the current state.

Client scripts only start once the player has joined the server, and the join waits until the game reaches GameState.InGame, which is the state the game is in while the world is loaded and the player plays. So in practice Game.GetState() returns GameState.InGame while your scripts run; the other states are passed through during startup and loading.

NameValueMeaning
GameState.Entry0The game has just started.
GameState.AwaitUnload1Waiting for data to unload.
GameState.StreamingInstall2Streaming install in progress.
GameState.Logout3Logging out of the platform account.
GameState.Title4The title screen.
GameState.Login5Logging in to the platform account.
GameState.EnumerateDLC6Checking which DLCs are installed.
GameState.LoadGlobal7Loading the game's global data.
GameState.WaitingForSave8Waiting for the save data.
GameState.GDPR9The data privacy (GDPR) consent step.
GameState.WaitingForGlobal10Waiting for the global data to finish loading. While the client downloads the server's resources, the game stays here.
GameState.LoadSpawn11Loading the area the player spawns in.
GameState.LoadWait12Waiting for the world to finish loading.
GameState.NewGamePlus13Starting a New Game+.
GameState.FadeOutTitle14Fading out of the title screen.
GameState.FadeToMain15Fading into the game.
GameState.InGame16In the game: the world is loaded and the player is playing.
GameState.Quit17The game is quitting.

Example

-- client: only do world work once the game is in its playing state
Cmd.Add("state", function()
if Game.GetState() == GameState.InGame then
print("in game")
else
print("still loading, state " .. Game.GetState())
end
end)