(This code is in a normal script not a local script) I'm just trying to simply have make a Data Store script to save money called "Dino Dollars". But when I run my game no errors occur but money doesnt save and when I manually run the script I keep getting the "DataStore can't be accessed from client" error. If anyone could see an error I dont that would be very helpful thx.
local DSS = game:GetService('DataStoreService'):GetDataStore('test1212123')
game.Players.PlayerAdded:Connect(function(plr)
local unique = 'id-'..plr.userId
local leaderstats = Instance.new('IntValue',plr)
local savevalue = Instance.new('IntValue')
leaderstats.Name = 'leaderstats'
savevalue.Parent = leaderstats
savevalue.Name = 'Dino Dollars'
local GetSaved = DSS:GetAsync(unique)
if GetSaved then
savevalue.Value = GetSaved[1]
print("First")
else
local NumbersForSaving = {savevalue.Value}
DSS:SetAsync(unique, NumbersForSaving)
print("ElseLine")
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local unique = 'id-'..plr.userId
local Savetable = {plr.leaderstats.DinoDollars.Value}
DSS:SetAsync(unique, Savetable)
print("Final")
end)
The error does not say what line it just says "DataStore can't be accessed from client".

1 comment
You cannot access datastores from a local script, just like the error says.