Here is my script.
--Locals local DataStoreService = game:GetService("DataStoreService") local MyDataStore = DataStoreService:GetDataStore("MyDataStore") --Stats adder game.Players.PlayerAdded:Connect(function(player) local leaderStats = Instance.new("Folder") leaderStats.Name = "leaderstats" leaderStats.Parent = player --Cash stats local Cash = Instance.new("IntValue") Cash.Name = "Cash" Cash.Parent = leaderStats -- Load Data local CashData local Success, errormessage pcall(function() CashData = MyDataStore:GetAsync(player.UserId.."-Cash") end) if Success then Cash.Value = CashData print("Data Loaded") else print("Data was NOT loaded :(") warn(errormessage) end end) --Saveing Stats game.Players.PlayerRemoving:Connect(function(player) local Success, errormessage pcall(function() MyDataStore:SetAsync(player.UserId.."-Cash",player.leaderstats.Cash.Value) end) if Success then print("Data Saved") else print("Data was not saved :(") warn(errormessage) end end)
I have a solution if API services are disabled, turn that on. If that doesn't work then I have my own leaderboard that saves and is much smaller. Feel free to use it
local datastore = game:GetService("DataStoreService") local ds1 = datastore:GetDataStore("CashSaveSystem") game.Players.PlayerAdded:connect(function(plr) local folder = Instance.new("Folder", plr) folder.Name = "leaderstats" local cash = Instance.new("IntValue", folder) cash.Name = "Money" cash.Value = ds1:GetAsync(plr.UserId) or 500 --You can replace 500 with how much you want the starting money to be at ds1:SetAsync(plr.UserId, cash.Value) cash.Changed:connect(function() ds1:SetAsync(plr.UserId, cash.Value) end) end)
I see you are doing this:
local Success, errormessage pcall(function()
But where is =
?
Try this:
local Success, errormessage = pcall(function()
There also could be some stuff about it in the output, this is where you should look for issues.