Roblox doesn’t allow RemoteFunctions in metamethods. The only thing I found is this workaround:
function mt.__index()
return function()
return func:InvokeServer()
end
end
print(sth.index()) -- print(sth.index)
Is there any prettier workarounds?
The simple reason is that metamethods cant yield, Binable.InvokeServer
yields the thread, which causes this error.
You’ll have to make a custom callback class to handle this, since then you can skip the yielding behaviour yourself instead of having it yield.
2 Likes
I know, but isn’t it bad that instead of just getting the value I have to manually call the getting function one more time?