#table passed as an argument being empty for some reason

1 messages · Page 1 of 1 (latest)

violet olive
#

server side

--first function
local jogsA = jogadores:GetChildren()
local jogsF = {}
for i = 1, #jogsA do
    jogsF[i] = game:GetService("Players"):GetPlayerByUserId(jogsA[i].Name).Name
end
ATUALIZARJOGADORES:FireClient(player, jogsF, 1)


--second function
local jogs = game:GetService("ServerStorage").Salas:FindFirstChild(sala).jogadores
local jogsA = jogs:GetChildren()
local jogsF = {}
for i = 1, #jogsA do
    jogsF[i] = game:GetService("Players"):GetPlayerByUserId(jogsA[i].Name).Name
end 

for i = 1, #jogsA do
        local jog = game:GetService("Players"):GetPlayerByUserId(tonumber(jogsA[i].Name))
    if jogsA[i].Name == tostring(host) then
        ATUALIZARJOGADORES:FireClient(jog, jogsF, 1)
    else
        ATUALIZARJOGADORES:FireClient(jog, jogsF, 0)
    end
end

client side

ATUALIZARJOGADORES.OnClientEvent:Connect(function(jogs, aux)
        local P
    local Pc
    local frameM = game:GetService("Players").LocalPlayer.PlayerGui.Main.Frame
    if aux == 1 then
        P = frameM.P5.Frame
    elseif aux == 0 then
        P = frameM.P6.Frame
    end
    Pc = P:GetChildren()
    for i = 1, #Pc do
        if not Pc[i]:IsA("UIListLayout") and Pc[i].Name ~= "Placeholder" then
            Pc[i].Visible = false
            Pc[i]:Destroy()
        end
    end
    print(jogs)
    print("print 1")
    for i = 1, #jogs do
        print("print 2")
        local jog = P.Placeholder:Clone()
        jog.Text = jogs[i]
        jog.Name = tostring(i)
        jog.Visible = true
        jog.Parent = P
    end
end)

when the event is fired by the first function, everything works, when its fired by the second function, not everything works, the table printed is empty, the "print 1" is printed but "print 2" isnt, i have no idea at how the table is being empty when fired by the second function (the whole script isnt written down, feel free to ask for more information if u need)

steep spindle
#

Not all type of data can be serialized

#

if you use multiple types of indexes for example string and number
One will be nil'ed

#

sometimes serialization can throw out other stuff like custom roblox classes

#

as they aint always serializable

violet olive
steep spindle
#

i dont think youre actually mixing types

#

but maybe im missing

violet olive
#

1, 2, 3, 4

steep spindle
#

i see

#

what exact data are you sending

#

im bit lost in the code

#

is it sending player and players name?

violet olive
steep spindle
#

from server to client

violet olive
#

first parameter is the player ofc, second is a table of many players names, the third is to tell which GUI to manipulate

#

that table is obtained by another table that is storing the players user id

steep spindle
#

and*

violet olive
#

if its fired by the second function

steep spindle
#

or the whole part

violet olive
#

second function on server side

#

the whole part yeah

steep spindle
#

alright alr i see

steep spindle
#

maybe you can try with player id

#

and then just get player on client

#

not sure if thats 100% it but always worth taking a look over

violet olive
steep spindle
#

yes

#

oh wait

#

im fucking stupid

#

i forgot how remote works

#

ok wait wait

#

😭

violet olive
#

dw

steep spindle
# violet olive dw

if u print the table right after on client event, its still empty right?\

violet olive
#

yes

#

the for loop isnt even executed

steep spindle
#

what does that show

violet olive
#

lemme see

violet olive
steep spindle
violet olive
#

apparently

steep spindle
#

if you set value of table to nil, it will be removed essentially gone
So if its not able to get player by id, it would be nil
But then name would have error, weird, add prints

#

imagine sending-

steep spindle
violet olive
#

im also getting this sometimes

#

not sure if its related

#

just sometimes, not always

violet olive
untold roostBOT
#

studio** You are now Level 4! **studio

violet olive
#

i think i got it

#

yep fixed

#

it was a typo

warped canyon