

Use LocalScripts if the client needs to create and remove gameplay instances tied to the new user, such as a GUI display for the user's stats on a custom leaderboard. Use Scripts to access server-related services, such as a data store to retrieve and save data when a user joins or leaves. They can also connect to the Player.CharacterAdded, Player.CharacterRemoving, and Humanoid.Died events to perform gameplay-related actions for when the character spawns, despawns, and dies.

LifecycleĬlient and server-side scripts can both connect to the Players.PlayerAdded and Players.PlayerRemoved events to perform actions in response to the lifecycle of a Player object. Each Player object represents a user in the experience, and it parents four important containers that you can use to customize a user's experience: Backpack, StarterGear, PlayerGui, and PlayerScripts. The Players service contains all the Player instances in an experience.

The Player object contains information about the user that's universal across experiences, such as their username, friend list, saved avatar character, and Roblox membership type, as well as properties, methods, and events that affects the user's lifecycle between joining and leaving your experience. When a user joins an experience, Roblox represents them as a Player in the data model.
