RemoteEvent isn't sending table

Basically, I’m making an inventory and I need a table to go from server to client. However, the table isn’t sending properly.

Server script:

game.ReplicatedStorage.Request.OnServerEvent:Connect(function(plr)
	print("Transfering data")
	local transfer = {}
	for i, v in ipairs(game.ServerStorage.Inventories[plr.Name]:GetChildren()) do
		table.insert(transfer, v)
	end
	game.ReplicatedStorage.Request:FireClient(plr, transfer)
	print("Fired. Here's the table: ")
	for i, v in ipairs(transfer) do
		print(v)
	end
end)

Client script:

game.ReplicatedStorage.Request.OnClientEvent:Connect(function(inv)
	print("Received inv.")
	for i, v in ipairs(inv) do
		print(v)
		local Frame = Instance.new("Frame")
		Frame.BorderSizePixel = 0
		Frame.Parent = script.Parent
	--	local Decal = game.ReplicatedStorage.Decals[v]:Clone()
	--	Decal.Size = UDim2.new(1,0,0.8,0)
	--	Decal.Parent = Frame
		local Button = Instance.new("TextButton")
		Button.Size = UDim2.new(1,0,0.2,0)
		Button.Position = UDim2.new(1,0,0.8,0)
		Button.BackgroundColor3 = Color3.fromRGB(0,170,0)
		Button.Text = "Equip " .. v
		Button.TextColor3 = Color3.new(1,1,1)
		Button.TextScaled = true
		local EquipScript = game.ReplicatedStorage.EquipScript:Clone()
		EquipScript.Parent = Button
	end
end)

The table has the required items when printing on the server, however when it gets to the client, the table is empty. Is there a reason for this?

Do you have an output (from the dev console) that you can send?

Sure:

output

Yeah it’s empty because of it’s a:

Non-Replicated Instances

If the value being sent is only visible to the sender, nil will be passed instead of the value. For example, if a server tries to pass a descendant of ServerStorage , the client listening to the event will see a nil value because that object isn’t replicated to the client.

Try Parenting it to replicated storage first then sending the information to the client.

5 Likes

Well, that was obvious…

Thanks! Now I know something new.

2 Likes