Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Unknown error when using DataStores and metatables?

Asked by
blowup999 659 Moderation Voter
6 years ago

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

Log in to vote
0
Answered by
H4X0MSYT 536 Moderation Voter
6 years ago

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.

Ad

Answer this question