my issue is that whenever i call the pcall the entire script aborts
i’ve tried alot of things, i’ve read official docs read free model code, check api access (api access is enabled), i’ve also watch youtube videos
this is the code
local function playerLeft(player)
if currentPlayersData[player.Name] then
-- currentplayersdata[player.Name]
-- this is not the issue
local plrData = currentPlayersData[player.Name]
local success, errorMsg
local attempts = maxAttempts
-- maxattempts = 5
local data = getSaveData(plrData)
-- getsavedata returns a table
repeat
print("before pcall")
-- code above this line runs
-- this pcall aborts the script for some reason
success, errorMsg = pcall(function()
return databank:SetAsync(getKey(player), data)
end)
-- this does not run below this
print("after pcall")
attempts -= 1
if not success then
warn(errorMsg)
task.wait(3)
end
until success or attempts == 0
if success then
print("saved: "..player.Name)
else
warn("not saved: "..player.Name)
end
print("call end")
end
end
game.Players.PlayerRemoving:Connect(playerLeft)
also it isnt providing any error, its just stopping
also the reason i put [URGENT] is not because I’m inpatient
I’m just in a time crunch, I’m not saying my request for help is more important than others, I’m just saying that i need to finish this project before a specific time.
Sorry, I do suppose that it looks like that, i just wanted to be clear
A thread can be suspended or running. To ensure execution, you can use task.spawn() around the pcall for asynchronous execution allowing the coroutine to run without interrupting the main thread, this is not really the recommended fix though.
you probably havent allowed access to API services in game
you arent seeing anything because the pcall is probably failing if it works in game
try enabling that in game settings
useful tip if youre making datastores