Basically, I'm trying to Sava Player's Points (IntValue not Leaderstats)
But I get Print: Data Not Saved
anyone knows why?
local DATASTORE = game:GetService("DataStoreService"):GetDataStore("DATASTORE")
game.Players.PlayerAdded:Connect(function(player)
local Points = Instance.new("IntValue")
Points.Name = "Points"
Points.Parent = player
local data
local dataSaved, notSaved = pcall(function()
data = DATASTORE:GetAsync(player.UserId.."Points")
end)
if dataSaved then
Points.Value = data
print("Data Saved")
else
print("Data not saved")
warn(notSaved)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local dataSaved, notSaved = pcall(function()
DATASTORE:SetAsync(player.UserId.."-Points", player.Points.Value)
end)
if dataSaved then
print("Data Saved")
else
print("Data not saved")
end
end)
local givePoints = game.ReplicatedStorage.givePoints
givePoints.OnServerEvent:Connect(function(player)
player.Points.Value = player.Points.Value + 1
end)

8 comments
Nope, It didn't work :/ I get Print "Data Saved" but data is not being saved (api is enabled)
I might know why. Try this: While playing your game in Studio, go to the Test section. There should be a button that says Current: Client. Click on this, and then change the value. This should fix your problem and I can explain why.
My Bad Haha, The values were updating from client side, would you mind if you explain a bit why we had to add like "-Points" on datastore?
Woops, I also realised that the Value is stuck to 110, and is not updating...
Woops, I also realised that the Value is stuck to 110, and is not updating...
So actually, there are many ways save data. I prefer using a table to save it, and then I get values from that table. So just using stuff like "-Points" is just another way of saving data. Also, could you mark my answer as correct please?
Oh sry I didn't see that until I did refresh lol.
I would assume this is not to do with the save system, however make sure to connect your increment function to a button to see if that will change the value. I assume it will.