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.

8 comments
are you changing the actual server side's stat not just the client side's
See, I'm not entirely sure... how would I change the server side stat?
basically is this a normal script or a local script
Normal
And it's inside server script service
To change the value on the server click on the 'Current' on the home tab at the top of your screen(while playing). It should say 'Current: Client', once you click it, it will take you to the Server Side, then go to Players, your player and change the value of your cash and see if it saves when you stop and play again.
Alright, thanks.
Ok, it works. The issue was the way I was adding to the value... My suspicion was right. How am I supposed to make it so that you click on something and it adds it through the server?