Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

table passed through FireClient becomes empty?

Asked by 5 years ago
Edited 5 years ago

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!

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) User#19524 175 — 5y
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 WillieTehWierdo200 966 — 5y
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 :( youracannonball 5 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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

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? youracannonball 5 — 5y
Ad

Answer this question