Table sent in Remote Event (server to client) is altered

Currently, I am trying to send a table of Instances with Textboxes to the client once loaded in, so that they can connect FocusLost events. The problem is, although the table of instances is originally correct in the script, once sent through the remote event it seems completely different? (however consistent)

script:

localscript:


(the final function will obviously not be on one line i just like small functions in one line while they’re short lmao)

here is the output:
image
as said before, this is consistent

1 Like

RemoteEvents/Functions do not support having non-string indices in tables, so if you try to pass something that isn’t a string, Roblox will implicitly coerce it into a string.

1 Like

strange, but alright…

i tried to produce a workaround for this, but this seems to produce its own problem? for some reason, the “UIObjects” inside the tables are wiped once sent now.

image

still closer than before though :grinning:

Instances sent to RemoteEvents must be replicated to the client, as they’re just sending a reference to the instance, rather than the instance itself.

im not sure what this means/how this applies to my problem…? the SurfaceGui instances are on clientside, as they can be found in the explorer tab in playtesting on client side, if this is what you mean. how would i refer to these SurfaceGui’s so that i can directly connect a FocusLost event to a TextBox inside of it?

Hmm, if the instances are replicated to the client then that shouldn’t cause any issues, not sure what could be causing the issue then.

nevermind sorry, apparently the TextBox isnt being replicated to the client??? when simply being sent through the remote event as a seperate variable, the client registers it as nil.
image
this is the models ancestry from the client view, which made me believe that the TextBox and SurfaceGui was being replicated to the client, however apparently they arent?
image

Is StreamingEnabled enabled by any chance? It could be that at the time the event got fired, the instance was not replicated yet.

i CAN confirm, this is the issue! StreamingEnabled is enabled, but i think this is more likely because of the fact the client is still loading in when CharacterAdded fires and so the TextBox hasnt yet been replicated to the client when the event is fired. i can prove this because when i add a task wait in the character added event before firing to the client, once the character has loaded in, the client now can see the TextBox variable! do you know a way i can yield this function so that it only fires to the client once all of workspace has fully been replicated? (obviously a task.wait is a pretty clumsy solution to finalize on haha)
image
ignore the sheeple i just needed a string i could recognise so that i could tell when the task.wait had finished yielding lol
image
(ClientSideGUIToReplicate and ClientSideGUIReplication are very close names but they arent the same variable)

Because StreamingEnabled is enabled, you can’t guarantee the whole workspace would be loaded, since it’ll only load the stuff in a specific radius.

The best solution here would probably to use CollectionService and then instead of firing a remote, you can just add a tag to the model, and then you can detect whenever the model is streamed in or streamed out on the client, and then just find the gui objects on the client.

You should also change the ModelStreaningMode of the modal to Atomic which makes it so either the whole model is streamed in or none of it, so you don’t have half the model streamed in.

1 Like

thank you for this solution and reccomendations! i wanted to learn/find a good scenario to use CollectionService for the first time and i seemingly stumbled upon it lol, it works perfectly here!
image

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.