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

Unknown error when using DataStores and metatables?

In a ModuleScript called from a Server Script within ServerScriptStorage I'm trying to use GetAsync with a datastore when a new index is created in a metatable.

However, I run it and I get this error.

15:18:44.513 - attempt to yield across metamethod/C-call boundary

--Stack stuff

15:18:44.903 - cannot resume non-suspended coroutine

--Stack stuff

I think it has something to do with ROBLOX's Thread Scheduler, but I've used datastores before and never had a problem. Does anybody know why this would error?

local playerData = setmetatable({}, {
	__newindex = function(self, index, plr)
		local data = gds:GetAsync(plr.userId .. "Data") -- Error 
	end;
})

game.Players.PlayerAdded:Connect(function(plr)
	playerData[#playerData + 1] = plr
end)

1 answer

I don't know much about meta-tables, but have you checked they can be converted into a JSON string? Roblox datastore saves data as JSON.

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