I'm trying to make a saving system but it won't save. I keep on getting this error: "SetAsync is not a valid member of IntValue"
Server Script (ServerScriptService)
--Varibles local DataStore = game:GetService("DataStoreService") local DataStoreoofs = DataStore:GetDataStore("SaveSystemoofs") local DataStorerank = DataStore:GetDataStore("SaveSystemrank") game.Players.PlayerAdded:Connect(function(player) --Create Leaderstats local LeaderStats = Instance.new("Folder", player) LeaderStats.Name = "leaderstats" --Create Values local oofs = Instance.new("IntValue", LeaderStats) oofs.Name = "OOFS" local rank = Instance.new("IntValue", LeaderStats) rank.Name = "RANK" --Quick Saves oofs.Value = DataStoreoofs:GetAsync(player.UserId) or 0 oofs:SetAsync(player.UserId, oofs.Value) rank.Value = DataStorerank:GetAsync(player.UserId) or 0 rank:SetAsync(player.UserId, rank.Value) --Values changed (save) oofs.Changed:Connect(function() DataStoreoofs:SetAsync(player.UserId, oofs.Value) end) rank.Changed:Connect(function() DataStorerank:SetAsync(player.UserId, rank.Value) end) end)
This will work.
Furthurmore, you shouldn't save as you load, because if datastore takes too long to respond, the player looses their stats, I would say that you should use an autosaver that saves every 30 seconds to 2 minutes.
Also, saving everytime a value is changed is ALSO a bad idea. What if someone keeps "oofing" / resetting, like 10 times a minute, this will result in dataloss.
USE AN AUTOSAVER AND GET RID OF QUICK SAVES
--Varibles local DataStore = game:GetService("DataStoreService") local DataStoreoofs = DataStore:GetDataStore("SaveSystem_oofs") local DataStorerank = DataStore:GetDataStore("SaveSystem_rank") game.Players.PlayerAdded:Connect(function(player) --Create Leaderstats local LeaderStats = Instance.new("Folder", player) LeaderStats.Name = "leaderstats" --Create Values local oofs = Instance.new("IntValue", LeaderStats) oofs.Name = "OOFS" local rank = Instance.new("IntValue", LeaderStats) rank.Name = "RANK" --Quick Saves oofs.Value = DataStoreoofs:GetAsync(player.UserId) or 0 DataStoreoofs:SetAsync(player.UserId, oofs.Value) rank.Value = DataStorerank:GetAsync(player.UserId) or 0 DataStorerank:SetAsync(player.UserId, rank.Value) --Values changed (save) oofs.Changed:Connect(function() DataStoreoofs:SetAsync(player.UserId, oofs.Value) end) rank.Changed:Connect(function() DataStorerank:SetAsync(player.UserId, rank.Value) end) end)