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.
What the message means
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
- The server never got the job
- A shared ModuleScript uses data stores
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.
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.
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.
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.
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.
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.
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.
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
- Open Output (Window menu, or the Script tab), clear it with Ctrl+K (⌘K on Mac), and press Play.
- Find the first red line. It starts with the script's place in the Explorer and the line number, such as
ServerScriptService.Shop:12:. - Click the red line. Studio opens that script with the cursor on the failing line.
- Read the lines between
Stack BeginandStack Endunder it: they list the calls that led there, newest first, so you can see which function called the broken one. - 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
- Roblox Creator Docs: data stores
- Roblox Creator Docs: remote events and callbacks
- Roblox Creator Docs: client-server runtime
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.