Answered Plainly
Display: Text size:

Saving a Player's Progress in Roblox

The short answer: Scores live in a folder called leaderstats that your script builds inside each player โ€” that is what the scoreboard in the game shows. But leaderstats vanishes when a player leaves. For progress that stays, the server saves it with DataStore, Roblox's saving service: load a player's saved value when they join, save it when they leave, and wrap every save and load in pcall because those calls travel over the network and can fail.

Step 1: leaderstats โ€” the scoreboard

This is the leaderboard script from Roblox's own points tutorial. Put a Script named Leaderboard in ServerScriptService:

-- Put this Script in ServerScriptService. Name it Leaderboard.
local Players = game:GetService("Players")

local function onPlayerJoin(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local points = Instance.new("IntValue")
	points.Name = "Points"
	points.Value = 0
	points.Parent = leaderstats
end

Players.PlayerAdded:Connect(onPlayerJoin)

What it does: every time a player joins (the PlayerAdded event from page 5), the script builds two things with Instance.new โ€” a Folder named leaderstats inside the player, and inside that folder an IntValue named Points starting at 0. Roblox shows the values inside a folder named leaderstats on the game's scoreboard automatically โ€” that exact name is the magic word. Other scripts change the score by changing Points.Value, exactly like the points plate patterns in this series.

The catch: leaderstats is rebuilt from scratch every join. Earn 500 points, leave, come back โ€” you are at 0 again. That is what DataStore fixes.

Step 2: DataStore โ€” saving for real

A data store is Roblox's way to keep data between sessions โ€” the documentation's own examples are things like a player's inventory or skill points. Data stores belong to the whole game: any place in the game, on any server, reads and writes the same data. Only server Scripts can use them โ€” a LocalScript that tries causes an error, which is exactly right for page 7's lesson: saving is the server's job, never the player's device's.

Add a second Script in ServerScriptService, named SavePoints:

-- Put this Script in ServerScriptService. Name it SavePoints.
-- It works together with the Leaderboard script.
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local pointsStore = DataStoreService:GetDataStore("PlayerPoints")

local function loadPoints(player)
	local leaderstats = player:WaitForChild("leaderstats")
	local points = leaderstats:WaitForChild("Points")

	local success, savedPoints = pcall(function()
		return pointsStore:GetAsync("Player_" .. player.UserId)
	end)

	if success and savedPoints ~= nil then
		points.Value = savedPoints
	end
end

local function savePoints(player)
	local leaderstats = player:FindFirstChild("leaderstats")
	if not leaderstats then
		return
	end
	local points = leaderstats:FindFirstChild("Points")

	local success, errorMessage = pcall(function()
		pointsStore:SetAsync("Player_" .. player.UserId, points.Value)
	end)

	if not success then
		warn(errorMessage)
	end
end

Players.PlayerAdded:Connect(loadPoints)
Players.PlayerRemoving:Connect(savePoints)

Walking through it:

Why every save wears a pcall

GetAsync and SetAsync are network calls โ€” your server asks Roblox's computers to fetch or store something. The data store guide is blunt about it: calls like these might occasionally fail, so you wrap them in pcall. pcall means "protected call": it runs the function, and if anything goes wrong it does not crash your script โ€” it hands you back success = false and the error message, so your game can warn you and carry on. An unwrapped save that fails takes the whole script down with it. A wrapped one just skips a beat.

Roblox's deeper player-data guide shows where the pros take this: keep the data in memory while someone plays, save when they leave, save again every few minutes in between as a safety net, and do a final save inside game:BindToClose() โ€” the hook that runs when a server shuts down, where save code gets about 30 seconds to finish. That same guide warns that its own full sample system is reference material, not code to drop into a game untested. Take the hint at every size: saving is the one system you test like you mean it, because a bug here does not crash a session โ€” it quietly eats somebody's progress.

Studio tests vs the live game โ€” read this before testing

By default, games tested in Studio cannot reach data stores at all. Your loads and saves will fail (your pcall catches the errors, so the game runs โ€” points just never persist). That is on purpose: Studio would be talking to the same data stores as your live game, and a test could overwrite real players' progress.

The data store guide gives the switch, for a published game:

  1. Open Studio's File menu, then Experience Settings.
  2. Go to Security.
  3. Turn on Enable Studio Access to API Services.
  4. Click Save.

And the guide's own warning, which matters more than the steps: do not enable this on a live game. Turn it on in a separate test version of your game, so your experiments can only ever touch test data. The honest summary:

Sources (official only; read in full November 7, 2026):

The save/load script's logic was run on this machine against a small fake Roblox setup before this page was written: a test player joined, earned 70 points, left, and rejoined โ€” and the saved 70 points loaded back, exactly as this page describes. Roblox API code itself only runs inside Studio, so the scripts were also checked line by line against the documentation above. Checked November 7, 2026.