Can't return a table through a RemoteFunction

Alright, thank you! :slightly_smiling_face:

1 Like

I found the source of information for you about what can be passed with remote events and remote functions: Custom Events and Callbacks | Documentation - Roblox Creator Hub - read under ‘Parameters’.

So, I thought I would clarify your response. Both a and b in your example can be passed through a RemoteEvent, RemoteFunction, BindableEvent, or BindaleFunction. However, a table with keys and an array cannot be used.

{ Name = "Test", Value = 5 } ✔️
{ 1, 2, 3 } ✔️

{ 1, 2, 3, A = "A", B = "B" } ❌
4 Likes

I thought I only used the

scenario?

Not necessarily,

You could send two tables then combine them later or send two sub tables,

You can send Instances through remotes as long as they are replicated,

The problem with Remote and Bindable Instances are they can only serialize data as much as JSONEncode can, only string keys, no mixed-tables, cyclic tables and no Metatables.

I dont see where I mix keys and arrays though.

You’re sending an array with ‘objects’ inside: {{Name = “test”}, {Name = “test2”}}.

So, what would be a good solution?

I don’t think I can send all the subtables separately.

Those aren’t Instances, they are strings, to make an Instance as a key you’ll need to enclose them in []


@tankattack9 you aren’t using a Mix-Table, I was elaborating on your question

Can I ask why you are using on Invoke Client, it’s not recommend

Have you heard about object oriented programming?

That’s not the issue of the OP’s problem, I send dictionaries across the network all the time.

I’m using InvokeClient mainly because it’s the first thing that came to my head about returning data from client, as that’s what it’s made for.

I had a similiar problem and this was my solution:

{{a = "a", b = "b"}, {a = "x", b = "y"}}

{"a", "b", "x", "y"}

and then you know that two first elements are from the first element of the original array and so on.

2 Likes

But I didn’t say that these are instances so I don’t know what you are talking about.

I assumed you miss understood that the OP is using Instances as a key, as you mentioned Objects, I don’t consider Dictionaries as objects but could just be me.


I’ll need to iterate through that table later on, how exactly do I know what belongs to each user?

As I said, you pack everything into one simple array. You have a PlayerID key at the beginning of every ‘set’ so it will look like that

{126753, 'somedata', 3, 238476, 'somedata2', 4}

as you can see you can get the original array from it simply by taking 3 first elements then next 3 elements. And at the beginning of every set you have the ID you need.
So e.g. the first set from my example is

126753, 'somedata', 3

then the second one

238476, 'somedata2', 4

Alright, thanks again! :ok_hand:

(Also it just so happens we are both from poland, funny coincidence.)

1 Like

Oh I didn’t notice, so good luck and cześć xd

2 Likes

@tankattack9 You shouldn’t use Invoke client but if you insist please warp it in a pcall.
(It’s exploitable and such)

You should rework your Server - Client relationship, this isn’t best practice as the Server shouldn’t have to request information from the Client but instead do Client requests.

Can we also see code for Music Training?

Perhaps it returns nothing that’s why it’s not printing, if that is the case the return code isn’t working right, because it won’t print nil unless you explicitly return nil

1 Like