It is currently impossible to send Random and TweenInfo userdata through remote events and functions.
I’ve tested every userdata listed on the developer hub by sending each userdata object through a remote event, from both the server to client and client to server (I will attach the place file below so you can test it out yourself). Of all the userdata I tested, only Random and TweenInfo did not replicate.
Both of these should replicate because in the wiki article on Remote Events and Functions, it says,
Any type of Roblox object (Enumeration value, instance, userdata) can be passed as a parameter in a RemoteEvent firing or RemoteFunction invocation.
[Edit]: I just remembered that newproxy is a userdata as well. I tested it and it also doesn’t go through remotes. I’m not sure if this should go through, but it would be nice to be able to send newproxys through remotes as unique objects…
Well, the documentation says that all userdata should be able to be sent, so I don’t think we should settle with workarounds.
P.S. You should read up on what you can send through remotes. I noticed you didn’t list tables… sending tables through remote events can be really useful sometimes.
Yeah, I just forgot to list tables. There’s tons of other things. I looked at devhub and you seem to be right:
Any type of Roblox object (Enumeration value, instance, userdata) can be passed as a parameter in a RemoteEvent firing or RemoteFunction invocation. Lua types (such as numbers, strings, boolean) can also be passed, although there there are some limitations on how data can be passed.
it would be nice to be able to send newproxys through remotes as unique objects…
Do you mean that you would like them to be received as metatable-less userdata? You could always just pass tostring(userdataValue) to get a 1-to-1 mapping between strings and userdata, which could act as such a unique object.
Passing metatables over the network would not make sense as this would basically lead to arbitrary Lua execution on the server (when the functions would be replicated). Server-to-client metatable replication could be more secure, but it would result in the API being asymmetrical, and would also be difficult to implement (taking closure variables of metamethods into consideration, etc.).
I also recently came across this issue, as I use a Random object on the server, and new players who join can’t have the current state of the object sent to them over remote.
That does not work for Random. As far as I can tell, there is no way to find the internal state to make a copy across the client/server boundary. But there should be.
What I want to be able to do is call Random.new() on the server then pass to FireAllClients() so that a randomized visual effect will look the same on all clients. But I currently have to use a workaround, where instead I call math.random(-0x7FFFFFFF, 0x7FFFFFFF) on the server and pass that to the client, before calling Random.new() with that value on the client.