simple all i want is just to send a table from the client to server but the problem is that when i send a table with values the table recieved in the server becomes empty {}
so how can i send the table with the values in it to the server, i don’t think remote events work because they send empty tables. any help will be appreciated !
Can you show us your code so we can get a better idea of the issue?
i mean its not that complex
here it is
local Script:
script.Parent.Parent.SendTotal.Event:Connect(function(Total)
local Games = {}
for i,v in pairs(script.Parent.Parent.Cart.CartOfGamesFolder:GetChildren()) do
if v:IsA("GuiObject") then
table.insert(Games,v)
end
end
print(Games)
game.ReplicatedStorage.GamesEvents.RemoteFunction:InvokeServer(Games)
end)
server script
game.ReplicatedStorage.GamesEvents.RemoteFunction.OnServerInvoke = function(Plr, Games)
print(Games) -- the print is {} it should contain the values inside the table
end
should add that moment to your “deforum moments”
If you want to print a table you need to use ToString(Games)
1 Like
I see no idea what is wrong with this just tell me what it is print for Games(table) in localscript?
This might work I have no idea to test this theory since I don’t have studio opened
nevermind i tried doing tostring but it doesn’t work
1 Like
i just want to test if the table is empty or not in the client, and when i print it, it isnt empty, but when i print it in server IT IS EMPTY for some reason
if you want to check if the table is empty or not then use #Games
if its empty then it will return 0 however if it is not empty it will return a number greater than 0
1 Like
I could be wrong cause Ive never used Invoke server or remote functions but shouldn’t your server code be like this?
game.ReplicatedStorage.RoGamesEvents.RemoteFunction.OnServerInvoke:Connect(function(Plr, Games)
print(Games) -- the print is {} it should contain the values inside the table
end)
EDIT : ignore this message I just looked up remote functions on dev hub my bad
wait i see the problem, you’re using .OnServerInvoke:Connect(function(plr, Games)
end)
To use on server invoke you need to do .OnServerInvoke = function(Plr, Games)
end
1 Like
it dosent work sadly , but people why are yall ignoring the main problem the main problem is not that i want to check if the table is empty or not what i want is to send the table from client to server simple.
is it printing anything when you try to do invoke server?
it is printing yes, but its printing an empty table like this
output :
{}
They want you to check if the table is empty to see if your sending an empty table to be server which would make sense why your server script is printing an empty table
Oh it was Vikram who suggested to do :Connect(function)
try using HttpService:JSONEncode()
when sending to the client and when the server receives it, use HttpService:JSONDecode()
1 Like
but its not sending an empty table and my evidence is the fact that when i print the table in the client before firing it to the server it dosent print an empty table it prints a table with values, thats why i said “print(Games)” in the client
By the way if you just want to send information from the client to the server, why not just trying to use a remote event?
(You can still fire information back to the client with a remote event too if that’s what you need)