of     1   

eRanged
#189988030Sunday, May 29, 2016 4:27 PM GMT

First time using pcall... local SaveAttemptsLeft = 3 --Attempts it tries to save if failed local function SaveData() if SaveAttemptsLeft > 0 then --If didn't try to save 3 times already local success, message = pcall(DataStore:SetAsync(key, savedData)) if success then print('Success') else SaveAttemptsLeft = SaveAttemptsLeft - 1 SaveData() --Pcalls again attempting to save data end end end SaveData() --Starts to try to save data
gskw
#189988255Sunday, May 29, 2016 4:30 PM GMT

No, you're passing the return value of DataStore:SetAsync to pcall() Do: local success, message = pcall(function() DataStore:SetAsync(key, savedData) end)
eRanged
#189989872Sunday, May 29, 2016 4:44 PM GMT

Like this? local SaveAttemptsLeft = 3 --Attempts it tries to save if failed local function SaveData() if SaveAttemptsLeft > 0 then --If didn't try to save 3 times already success, message = pcall(function() DataStore:SetAsync(key, savedData) if success then print('Save Successful for ' .. player.UserId) else SaveAttemptsLeft = SaveAttemptsLeft - 1 SaveData() --Pcalls again attempting to save data end end) end end SaveData()
gskw
#189990072Sunday, May 29, 2016 4:46 PM GMT

You missed the "end)" at the end of the line
gskw
#189990178Sunday, May 29, 2016 4:47 PM GMT

Or rather, you put it in the wrong place.
eRanged
#189990245Sunday, May 29, 2016 4:47 PM GMT

i have a "end)" there
eRanged
#189990421Sunday, May 29, 2016 4:49 PM GMT

I'm not getting any errors about the end? local SaveAttemptsLeft = 3 --Attempts it tries to save if failed local function SaveData() if SaveAttemptsLeft > 0 then --If didn't try to save 3 times already success, message = pcall(function() DataStore:SetAsync(key, savedData) if success then print('Save Successful for ' .. player.UserId) else SaveAttemptsLeft = SaveAttemptsLeft - 1 SaveData() --Pcalls again attempting to save data end end) end end SaveData()
WoolHat
#189992038Sunday, May 29, 2016 5:02 PM GMT

success, message = pcall(function() DataStore:SetAsync(key, savedData) if success then print('Save Successful for ' .. player.UserId) else SaveAttemptsLeft = SaveAttemptsLeft - 1 SaveData() --Pcalls again attempting to save data end end) You cannot access what "success" is inside of the pcall itself. You need to decide what to do AFTER you get the results from pcall. Should be: success, message = pcall(function() DataStore:SetAsync(key, savedData) end) -- end) moved here if success then print('Save Successful for ' .. player.UserId) else SaveAttemptsLeft = SaveAttemptsLeft - 1 SaveData() --Pcalls again attempting to save data end
eRanged
#189993527Sunday, May 29, 2016 5:15 PM GMT

OH thxs
chimmihc
#189998643Sunday, May 29, 2016 6:04 PM GMT

There is no need to wrap it in a new function. success, message = pcall(DataStore.SetAsync,DataStore,key, savedData)
eRanged
#190018389Sunday, May 29, 2016 10:14 PM GMT

Chim how would I put it inside the function, it keeps giving me errors: This is what I got for now. local SaveAttemptsLeft = 3 --Attempts it tries to save if failed local function SaveData() if SaveAttemptsLeft > 0 then --If didn't try to save 3 times already success, message = pcall(function() DataStore:SetAsync(key, savedData) end) if success then print('Save Successful') else SaveAttemptsLeft = SaveAttemptsLeft - 1 SaveData() --Pcalls again attempting to save data end end end SaveData()

    of     1