How to send tables through remote events

so im firing a remote event from server to client and in the server script i have a table of all the users datastore data

how would i send a table through a remote event?

i tried json encoding then decoding but that didnt work

4 Likes

i don’t know if this is efficient but,

local function CopiedTable(TableOfSomeone)
	  local Copia = {}
	for key, value in pairs(TableOfSomeone) do
	Copia[key] = value
           end	
      return Copia
end

	local cloneVariable = CopiedTable(TableOfSomeone)


		
	local SentTable = RS:WaitForChild("PlayerData"):WaitForChild("SendingTable")
	SentTable:FireClient(player, cloneVariable)

Put the table in a variable and then send this variable in the remote event parameters.

(forgot how to do the lua thing in posts)

Server Script:

local Table = {

Value1 = 200,
Value2 = 300

}

YourRemoteEvent:FireClient(Table)

Client script:

YourRemoteEvent.OnClientEvent:Connect( function(Table)

print(Value1)
print(Value2)

end)

(I tested this in roblox studio, it worked for me)

5 Likes

oh i see where i went wrong, im actually stupid lol i forgot the :Connect

my biggest apologies but thanks so much

1 Like

How did you made the lua thing?

Oh lol, did you know how to do the lua thing?

wait like how i made the fire client and connect function?

I don’t put in my ansawer but to fire client you need to put the name of the client you wanna fire first

yeah i know, thanks for the help btw

1 Like

Nobody said how to do the lua thing in devforum :frowning:

well your response helped me out soooo

Don’t worry i’ll search in google

no dude you literally helped there is no longer a problem

Ik i helped i said that i’ll search how to do the lua console in devforum bro, like the “moleza” made

Oh you was thinking i was trying to solve the solved problem? I don’t noticed cuz my english isn’t so good

ahh i see well my apologies then

Just store the table (be it a dictionary or array) inside a variable and pass that as an additonal argument to any “FireServer()”, “FireAllClients()” or “FireClient()” function call made through a “RemoteEvent” instance.

2 Likes

To put lua you just say:
` three of these at the start of your lua code and at the end