Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

table passed through FireClient becomes empty?

SERVER

	...
	local playerspets = a:getTable()
	print(#playerspets) -- This prints the correct length of the table
	drawinv:FireClient(player, playerspets) 
	
end

LOCALSCRIPT

	...
	 draw.OnClientEvent:Connect(function(playerpets)
		print(#playerpets) -- This prints 0 aka the incorrect length

Maybe i'm missing something but I've been stuck on this for a while. If anyone could help me out that would be greatly appreciated, thanks!

3 comments

0

When you send a table like that, a copy of the table is received/sent, and any metatable data is lost, as well as non-numerical indices (I think)

0

See this section of the Wiki page on Remote Functions & Events for the limitations on data sent over the network: http://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events#Limitations

0

Hm, I must have missed that oops. So how would I go about getting a serverside table to the client? I currently have the players pets set in a folder in ServerStorage and I need to get it on a local script :(

1 answer

if you want to print the length then just fire the value of the length, not the whole table, like this:

Server:

    ...
    local playerspets = a:getTable()
    drawinv:FireClient(player, #playerspets) 

end

Client:

...
 draw.OnClientEvent:Connect(function(playerpets)
    print(playerpets)

Hope this helped

1 comment

0

Sadly I have to get the values of that table, I was just using print to see if it was getting the values. Although i'm kinda lost on how id go about getting that table if I can't pass it through. Any ideas?

This discussion is preserved as it was. New answers, comments, and votes are closed.