Server Table to Client?

Hello, I’ve been trying to code something recently. I need it so that the server makes a table of certain entity names and then sends it to the client, but these User messages keep confusing me and screwing stuff up. I need help I’ve been trying for quite a while now. Here’s what I’m at right now.

Serverside:
[lua]
function SendText( ply, txt )

umsg.Start("my_variable_message")
    for i=1, 9 do
        umsg.String( text_to_send* )
    end
umsg.End()

end

local text_to_send = {}

local slot = 0

for k,v in pairs(ents.GetAll()) do

    local var1 = tostring(v:GetName())

    if string.sub(var1,1,6) == "space0" then
        slot = slot + 1
        text_to_send.slot = var1
    end

end

SendText( player.GetAll(), text_to_send )
[/lua]

Clientside:
[lua]
– i already know this one won’t work, tell me how though
local mytable = {}

function my_variable_message_hook( um )

for i=1,9 do
    Msg( "Line "..i..": \""..um:ReadString().."\"

" )
end

if string.sub(var1,8,11) == "red" then --this is the start of the string checker
    mytable[var1]="red"
elseif string.sub(var1,8,12) == "blue" then
    mytable[var1]="blue"
elseif string.sub(var1,8,13) == "green" then
    mytable[var1]="green"
elseif string.sub(var1,8,12) == "gold" then
    mytable[var1]="gold"
end--end of string checker

end
[/lua]

First, I need help actually getting the variables to the client, then I need to know how I can set up that string checker for them because I’m pretty sure var1 won’t work on the client.
I’m probably doing something completely wrong, or stupid. Also, if there’s an easier way please tell. Thanks :slight_smile:

umsg.String( txt* )

should fix it, text_to_send isnt defined untill after the function

Yes! I finally got it working, thank you so much :smiley: