Roblox Studio error

DataStore can't be accessed from client

What DataStore can't be accessed from client means in Roblox Studio, the three things that cause it with the code that triggers each, and the fix for each one.

Updated 14 November 20264 min readErrorLuauWritten by

In short

Data stores only work on the server. When a LocalScript, or a ModuleScript that a LocalScript requires, calls DataStoreService, Roblox stops it with this error. Do all saving and loading in a Script in ServerScriptService. When the player's screen needs the data, or a button should save, use a RemoteEvent or RemoteFunction to ask the server, and let the server decide what to save.

  • Data stores are server-only: Scripts, not LocalScripts.
  • A ModuleScript runs wherever it is required, so a shared module that touches data stores breaks on the client.
  • The client asks; the server checks and saves. Never let the client send the values to save.
On this page
  1. What it means
  2. Causes and fixes
  3. Fix it with RoCode
  4. Find the line
  5. Questions
  6. Sources

What the message means

Output (example)
Players.Builderman.PlayerScripts.SaveButton:4: DataStore can't be accessed from client

Roblox's docs say it directly: the server can only access data stores through Scripts, and client-side access in a LocalScript causes an error. Anything a client can do, an exploiter can do too, so letting clients write saved data would let anyone give themselves coins.

The script named in the message is the one that called DataStoreService. If it is a ModuleScript in ReplicatedStorage, look for the LocalScript that required it: the module ran on that player's device.

Causes and fixes

Three things cause this error in practice. Each one below has the smallest code that triggers it, then the fix.

A LocalScript tries to save or load

A save button or a settings menu lives in the player's GUI, so it is tempting to save from its LocalScript. The data store call has to move to the server.

Breaks LocalScript in StarterGui named SaveButton
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")

local store = DataStoreService:GetDataStore("Settings")
local player = Players.LocalPlayer

script.Parent.Activated:Connect(function()
	store:SetAsync(tostring(player.UserId), { music = false })
end)

The button fires a RemoteEvent with only the choice the player made. The server checks it and saves. This LocalScript sits inside the button.

Fixed LocalScript in StarterGui named SaveButton
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local saveSettings = ReplicatedStorage:WaitForChild("SaveSettings") :: RemoteEvent
local button = script.Parent :: TextButton

button.Activated:Connect(function()
	saveSettings:FireServer(false) -- music on or off, nothing else
end)

Add a RemoteEvent named SaveSettings to ReplicatedStorage. The server Script that saves is in the next section: it accepts only a boolean, so a client cannot send anything else to the data store.

The server never got the job

Moving the button is half of it: the save itself must be in a server Script that validates what the client sent. Without it, the RemoteEvent fires and nothing is saved.

Breaks LocalScript in StarterPlayerScripts named SettingsClient
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local saveSettings = ReplicatedStorage:WaitForChild("SaveSettings")

-- no server Script listens, so the setting is never saved
saveSettings:FireServer(false)

Add the server Script. It checks the type of the value, saves inside pcall (data store calls can fail) and only for the player who sent it.

Fixed Script in ServerScriptService named SettingsServer
local DataStoreService = game:GetService("DataStoreService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local store = DataStoreService:GetDataStore("Settings")
local saveSettings = ReplicatedStorage:WaitForChild("SaveSettings") :: RemoteEvent

saveSettings.OnServerEvent:Connect(function(player: Player, musicOn: unknown)
	if typeof(musicOn) ~= "boolean" then
		return -- ignore anything that is not true or false
	end
	local ok, err = pcall(function()
		store:SetAsync(tostring(player.UserId), { music = musicOn })
	end)
	if not ok then
		warn("[Settings] save failed for", player.Name, err)
	end
end)

A shared ModuleScript uses data stores

A data module in ReplicatedStorage is visible to both sides. When a LocalScript requires it, for example to read a shop price that lives in the same module, its data store line runs on the client and fails.

Breaks ModuleScript in ReplicatedStorage named PlayerData
local DataStoreService = game:GetService("DataStoreService")

local PlayerData = {}

PlayerData.store = DataStoreService:GetDataStore("PlayerData")
PlayerData.prices = { Sword = 100, Shield = 75 }

return PlayerData

Split it. Shared facts the client may read (prices, item names) stay in ReplicatedStorage. Anything that touches data stores moves to a module in ServerScriptService, which clients cannot see or require.

Fixed ModuleScript in ReplicatedStorage named Shop
local Shop = {}

Shop.prices = { Sword = 100, Shield = 75 }

return Shop

Fix it in your place

Paste the error, RoCode fixes it in your place

Copy the line from Output and paste it here. RoCode opens the script it names in the place you have open in Studio, works out which of the causes above it is, and edits the code there instead of handing you a snippet to paste.

For example: Players.Builderman.PlayerScripts.SaveButton:4: DataStore can't be accessed from client

RoCode is an AI agent for Roblox Studio: it reads the scripts in the place you have open, finds the line and edits it there, and every change is an undo point. It runs on Windows or macOS with a desktop browser. Free to start, with free credits every day.

How to find the line that causes it

  1. Open Output (Window menu, or the Script tab), clear it with Ctrl+K (⌘K on Mac), and press Play.
  2. Find the first red line. It starts with the script's place in the Explorer and the line number, such as ServerScriptService.Shop:12:.
  3. Click the red line. Studio opens that script with the cursor on the failing line.
  4. Read the lines between Stack Begin and Stack End under it: they list the calls that led there, newest first, so you can see which function called the broken one.
  5. Still not sure which value is wrong? Add print(typeof(x), x) just above the line, or set a breakpoint on it and read the values in the Watch window.

Questions

Can a LocalScript ever use DataStoreService?

No. Roblox's docs say data stores are reached through server Scripts only. The client asks the server with a RemoteEvent or RemoteFunction, and the server reads or writes.

How do I show saved data on the player's screen?

Load it on the server when the player joins, then copy what the GUI needs into leaderstats values, attributes on the Player, or a RemoteEvent the LocalScript listens to.

Why not let the client send its coins to save?

Because an exploiter can send any number. The server should keep the real values and save those; the client only says what it wants to do, such as "buy Sword", and the server checks it.

Can RoCode fix it?

Yes. Paste the Output line into RoCode. It moves the data store code into a server Script in your open place and connects the GUI to it with a remote.

Sources and further reading

How the code was checked: every block marked Fixed passes Luau's strict type checker against Roblox's API definitions (luau-lsp, 14 November 2026), and every block marked Breaks compiles and fails only when it runs. The message wording was checked against the message strings in Roblox Studio itself (macOS build installed 12 November 2026) and the data stores page of Roblox's Creator Docs on 14 November 2026. A type check catches misspelt APIs and wrong types, not game logic, so playtest in Studio before you publish.

More Roblox errors

All Roblox Studio errors

Stop hunting errors line by line.

RoCode reads the scripts in your open place, fixes the error where it happens and tells you what it changed. Free every day, no card required.