A way to send instances from client to server?

Is there a way to send instances from client to server?
If I fire a instance that only exists on client, it returns nil on the server.

1 Like

You don’t. The server would need to reconstruct the instance on their end if they wanted to work with it.

You could have the instance created by the server and managed by the client instead unless you require the client to be the creator of the instance and it shouldn’t be replicated to other clients. If the client creates it then you’ll need a purely data-oriented approach to “work” with it on the server.

Instances are sent as references through remotes so if the environment can’t acquire the reference then, as you’ve seen, it’s nil. The server does not have any references to client-created instances like how the client doesn’t have any references to descendants of server-sided services. These references can’t be created by the developer.

5 Likes

Well what if you just send every property of instance even the class name?

If that helps you in reconstructing the instance but I don’t particularly think that’s practical. Could you detail your exact use case and scenario? What are you trying to accomplish here that requires you to send a client-created instance to the server?

1 Like

Basically, I want all of player’s gui and it being sent to another client, being viewable to another client.

In this case it’d be more sound for the “receiving” client to reconstruct the Guis on their own end and then have the “sending” client replicate instructions via the server for the receiver to follow. In most cases of hand replication you don’t want to actually reconstruct any instances but instead communicate changes with data and then present them on the current client’s display.

2 Likes

do it directly on the server

But how would I get all of instance properties? there is no function like ‘GetProperties()’

Just made this module for you for that purpose.

Usage:

  1. Require the module anywhere on the server (this will set up the properties for the client)
  2. Now you can require it on either the client or server and use it as this:
local methods = require(...)
print(methods:GetProperties(workspace)) --> {...}
1 Like

Go to the settings gear next to the properties panel and turn off ‘log mode’. It’s a table viewer when you do that, it returns a table with the properties but that visualizes it for you.

I tried sending properties to the server and it’s doing nothing.
Try to fix something here:
place.rbxl (238.1 KB)
Try making a instance in workspace but in client, then check it if it exists on server.