So while using SetAsync with datastore service I ran across an issue where it wouldnt work and throw an error “attempt to call a string value”. It didn’t directly give me the error message but here’s my code:
module.SaveData = function(plr)
-- Save player data --
print(plr.Name.." is having their data saved")
-- Get player's current stats --
local leaderstats = plr:WaitForChild("leaderstats")
local coins = leaderstats:WaitForChild("Coins").Value
local regen = plr:WaitForChild("RegenUpgrade").Value
local reward = plr:WaitForChild("RewardUpgrade").Value
-- Store in table and save it to datastore --
while true do
local s, e = pcall(coinsDS:SetAsync(plr.UserId, coins))
local s2, e2 = pcall(regenUpgDS:SetAsync(plr.UserId, regen))
local s3, e3 = pcall(rewardUpgDS:SetAsync(plr.UserId, reward))
if e or e2 or e3 then
task.wait(retryTime)
print("Error while saving "..plr.Name.."'s data, retrying.")
print(e)
print(e2)
print(e3)
print(s)
print(s2)
print(s3)
continue
end
break
end
end
The datastores whos’ asyncs are being set are equal to DSS:GetDataStore(“Name”)
When printing all the successes and the errors, all the successes equaled false and the errors were what I stated above.