PlayerGui and StarterGui are where GUI objects are stored and shared so they can be made visible to players. Anything placed in the StarterGui will be copied into the PlayerGui folder for each player by default. Each player has its own PlayerGui loaded once their character is loaded. This only happens the first time the Player is loaded into the game. When the character respawns the PlayerGuis are cleared.
The StarterGui object holds GUI objects and LocalScripts. By default, children of this object are copied into all Player’s PlayerGui when their character spawns.
For mobile devices, the StaterGui’s desired default screen orientation can be set using ScreenOrientation. This setting gets copied into the Player’s PlayerGui ScreenOrientation property to determine the Player’s screen orientation on mobile.
The PlayerGui object holds the GUI objects that will be displayed to the player. If a ScreenGui is a child of a PlayerGui, then any GuiObject inside of the ScreenGui will be drawn to the player's screen. Any LocalScript will run as soon as it is inserted into a PlayerGui.
When a player first joins a game, their PlayerGui is automatically inserted into their Player object. It is good practice to use WaitForChild() to access the contents of PlayerGui as the Player must load before PlayerGui is inserted into the Player. The code below demonstrates this.
-- Accessing PlayerGui from a LocalScript: local Players = game:GetService("Players") local player = Players.LocalPlayer local playerGui = player:WaitForChild("PlayerGui")
When the player's Character spawns for the first time, all of the contents of StarterGui are automatically copied into the player's PlayerGui by default. As long as Players are set to respawn automatically (CharacterAutoLoads set to true) each time the Player respawns the contents of the Player’s PlayerGui will be cleared and replaced by the contents of StarterGui. Anything in a Player’s PlayerGui will be displayed on the screen for that player.