Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

UpdateAsync Callbacks cannot yield?

I can't figure out where it is yielding causing the "Callbacks cannot yield" error

DataStore:UpdateAsync(tostring(DateInfo.Date()), function(oldTable)
	if oldTable then
		local newTable = oldTable
		local str = "User ["..Sender.Name.."] Command ["..c.."] ".."Players present ["..Playerz.."]"
		table.insert(newTable, str)
		return newTable
	else
		local newTable = {}
		local str = "User ["..Sender.Name.."] Command ["..c.."] ".."Players present ["..Playerz.."]"
		table.insert(newTable, str)	
		DataStore:SetAsync(tostring(DateInfo.Date()), newTable)				
	end
end)

1 answer

✓ Accepted answer

The problem is that SetAsync is a YieldFunction, meaning it yields. I think you intended for it to be:

return newTable

This discussion is preserved as it was. New answers, comments, and votes are closed.