local DataStore = game:GetService("DataStoreService"):GetDataStore("MyData")
local success, response --Don't need to define yet
local count = 0 --1
while not success do --2
if count >= 1 then
warn("Retrying, count:", count, "\nError:", response) --3
wait(7) --4
end
success, response = pcall(DataStore.GetAsync, DataStore, "key") --5
count = count + 1 --6
end
I would like to make a function that would take advantage of the same code for both GetAsync as SetAsync, ie, in pcall(DataStore.GetAsync, DataStore, "key"), the GetASync should be actually the function argument.
local ds = game:GetService("DataStoreService"):GetDataStore("MyData")
function get(f, ...)
return f(...)
end
get(function(...)
return ds:GetAsync(...)
end, "key")
After refreshing my brain a bit, I realized the problem was simpler than I thought.
Just pass the argument exactly as it is executed in the example, ie MyFunction(DataStore.GetAsync) …