Promises and RemoteFunctions

Hello,

Apologies in advance if this is the wrong category

Is it possible to share a Promise object on the server with the client? And if there is a way can you show me?

Thanks

I don’t think so. Promises are really just tables, any time a table crosses the client/server boundary, only a clone of the table is sent, not a reference to the actual table.

1 Like

Found a solution,

RemoteFunctions will return the tables without the indexes of the functions, so if you just call setmetatable on the retuned value and set it to its previous metatable, then you will have the same thing.

I’ve never worked with promise objects (never needed to), but metatables are lost if their tables are transferred across the client-server network boundary, the easiest solution is to simply transfer both tables (primary table and its metatable) and then on the opposite end of the network layer call the setmetatable() global on the table and its desired metatable.

More information regarding network objects and metatables can be found here.
https://create.roblox.com/docs/scripting/events/argument-limitations-for-bindables-and-remotes#metatables