The Players service, the PlayerAdded event that greets everyone who joins, and why the server knows who's asking.
Every person in your game is a Player object, and Roblox keeps them all in one place: the Players service. Nearly every multiplayer feature starts by grabbing it.
Roblox groups its features into services, and you reach them all the same way:
local Players = game:GetService("Players")
This line is the doorway. From here, Players has everything player-shaped: who's in the game, when someone joins, when someone leaves.
game:GetService("...") is how you get every service — Players, DataStoreService, ReplicatedStorage, and more. One pattern, used everywhere.
Which line gives you access to the Players service?
PlayerAdded fires the moment a player joins the server — once per player, in order:
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
print(player.Name .. " joined!")
end)
The callback receives the new player's object. This is where you'll build their leaderstats, load their saved data, and set up everything they need before they spawn.
A player can also rejoin — leave and come back — which fires PlayerAdded again. The event is per join, not per person.
The event that fires when a player joins is called .
On the client side, there's a special shortcut: game.Players.LocalPlayer. It's the player running this computer — your own character from your own screen.
-- LocalScript
local Players = game:GetService("Players")
local me = Players.LocalPlayer
There's no LocalPlayer on the server (the server has no "me"). That's why you'll see LocalPlayer only in LocalScripts.
Write the two lines a LocalScript needs to grab the current player's name into a variable called me.
-- get the players service, then LocalPlayer
Next: telling every player apart forever — UserId.