Hi, I'm creating a "coins" system for a new game I'm working on. I'm going to be creating a new DataStore for new players which will have a base amount of 100 coins. This is my first time using pcalls to handle errors with DataStore, and would like to ensure that this is the best / most efficient way of doing it.
For context, this is a module script where scripts will contact it to change cash values for players.
local DSS=game:GetService("DataStoreService")
local CoinStorage=DSS:GetDataStore("Coins")
local module = {}
module.SetBaseCoins=function(Key)
local Success,Error=pcall(function()
CoinStorage:SetAsync(Key,100)
end)
while not Success do
print("SetBaseCoins Error:"..Error)
wait()
local Success,Error=pcall(function()
CoinStorage:SetAsync(Key,100)
end)
end
end
--[[module.getValue = function(key)
storage:GetAsync(key)
end
--]]
return module
