I was using a bunch of different datastore scripts, none of them worked and I was stumped, I decided to use the Alvinblox one and it didn't work, I went into the console and saw that the datastore was set to the right value, but it wasn't changing the leaderstats to that value.
local DataStoreService = game:GetService("DataStoreService") local myDataStore = DataStoreService:GetDataStore("myDataStore") game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local cash = Instance.new("IntValue") cash.Name = "Dollaroos" cash.Parent = leaderstats local data local success, errormessage = pcall(function() data = myDataStore:GetAsync(player.UserId.."-cash") end) if success then cash.Value = data else print("There was an issue saving your data") warn(errormessage) end end) game.Players.PlayerRemoving:Connect(function(player) local success, errormessage = pcall(function() myDataStore:SetAsync(player.UserId.."-cash",player.leaderstats.Dollaroos.Value) end) if success then print("Player Data Successfully Saved!") else print("There was an error when saving data") warn(errormessage) end end)
all I did was modify his script because I didn't want to break it.