I’m trying to send a table of Tools from the Server to the Client, as the tools are in ServerStorage. Currently, I’m trying to do this via a RemoteFunction however the table is always returning nil on the client. Is there anyway I could do this better, I’ve tried RemoteEvents however they still are returning nil.
ReturnTools.OnServerInvoke = function(player)
local tools = {}
for _, item in pairs(ServerStorage:GetChildren()) do
if item:IsA("Tool") then
table.insert(tools, item)
end
end
return tools
end
Client Code:
local ReturnedTable = ReplicatedStorage.TKServingSystem.ReturnTools:InvokeServer()
for _, v in ReturnedTable do
print(_, v) -- never prints
end
There is, in some previous debugging before I returned the table of tools, I iterated through the table and printed each tool, which did work perfectly fine. There’s nothing wrong on the server side, it must be an error sending it between. I have looked into unpacking the table but still, returns nil.
Your script returns nil because you need to clone the object and set the parent to a service that is accessible to both sides, such as ReplicatedStorage. Or you can simply change the parent manually or with a script.
If you have the ability to clone an object and set the parent to workspace or replicatedStorage, I highly recommend doing so.
I appreciate your input, however I couldn’t facilitate that as this is on a scale of ~100 tools and that would be performance heavy. However I’ve decided to send the table of strings (the tool’s names) to the client which works, as the client actually doesn’t need the Tool Object.