FireClient Remotes only passing one element of table/dictionary

Im attempting to make a system where the client requests a table containing dictionaries with object information, problem is whenver the client receives the table, only one element gets received. The one element that gets received has everything it should have came with but I cant really do much with just one element of my table.


Heres an image of the server script and the output. The client is directly printing the argument its receiving.

Ive also tried using a remote function instead of an event but the same thing happens.

Remotes.GetReadyDroppers.OnServerInvoke = (function(plr)
	print("Globally Readied Droppers: ", ReadiedDroppers)
	local PlyrsReadyDroppers = {}

	for dropper,data in pairs(ReadiedDroppers) do
		if data.PlayerID ~= plr.UserId then return end
		PlyrsReadyDroppers[dropper] = {
			dropping = data.dropping,
			PlayerID = data.PlayerID,
			dropLocation = data.dropLocation
		}
		ReadiedDroppers[dropper] = nil
	end

	print("Sending ", plr, " Mass Drop Data: ", PlyrsReadyDroppers)
	return PlyrsReadyDroppers
end)

The script handling these functions is a module and heres the client code just in case

local MassDropData = Remotes.GetReadyDroppers:InvokeServer()
		print("Client received Mass Drop Data: ",MassDropData)
		
		for dropper,data in pairs(MassDropData) do
			local DropperHead = dropper
			local clonedDropping = data.dropping:Clone()
			print("Dropping Cloned: ",clonedDropping)
			clonedDropping.Parent = workspace.Droppings
			if clonedDropping:IsA("BasePart") then
				clonedDropping.Position = data.dropLocation
			else
				clonedDropping:MoveTo(data.dropLocation)
			end


			clonedDropping.Owner.Value = Players.LocalPlayer.UserId
		end

Is there any work arounds to this? Or alternatively, a different way of looking at this issue? (Issue being that network receive is incredibly high due to the amount of Remotes are being fired to the client from the server.

2 Likes

jsonencode the table, send the encoded table with the remote, jsondecode it on the client

1 Like

Looked over the documentation and tried it out myself, didn’t work due to the fact that some pieces of the table are instances and a Vector3 which arent supported by jsonencode.


Is there a way to convert paths or vectors into strings?

On line 21 you are returning if the if statement is false, perhaps change it to continue instead of return. This is under the assumption that not all droppers are eligible to be sent so the 2nd one is returning the entire thing, and could be the reason as to why you are not receiving the data properly.

I dont think my if statement there is an issue, if the dropper is not owned by the player(is nil or a number that isnt the players UserID) then dont do anything.
Also I’m printing the array after the for loop which shows that the filtered array has all the instances(Makes sense cause since Im testing in studio, Im the only person in the server. Therefore every dropper that exists should be my own droppers.)

You’re right, I made an oversight. Is it possible that we could see the .OnClientEvent for the MassDropSignal event?

1 Like

Sure thing!
image

I must admit, I am stumped by this. There doesn’t seem to be a reason as to why this isn’t working as you are intending it to do so. All I can say for now is make sure there isn’t a variable with the same name(“MassDropData”) in the script with the .OnClientEvent.

1 Like

Yeah there isnt. I may have to approach my problem in a different manner if I can’t get my current idea to work out
Thanks for the inputs so far though!

Let us know if you find out a solution! I’ll probably walk away and reappear later, hopefully with an answer(if one isn’t provided already). Though(completely irrelevant to the problem at hand), couldn’t you just set the data to each entry like this?

PlyersReadyDroppers[dropper] = data

Instead of

PlyersReadyDroppers[dropper] = {
   dropping = data.dropping,
   PlayerID = data.PlayerID,
   dropLocation = data.dropLocation
}
1 Like

Created a dictionary inside of the table then made the dropper key, instead of putting the dropper key directly inside the table.

Also update:
I managed to convert everything into a string and noticed that for some reason the data decoded from the json only includes a singular piece key and its elements for some reason. Anybody know a reason why? The further and further I go into this the more lost Im getting

Code used:

Remotes.MassDropSignal.OnClientEvent:Connect(function(MassDropData)
	print("Client received Mass Drop Data: ", MassDropData)
	local DecodedData = HTTPService:JSONDecode(MassDropData)
	
	print("Client Decoded Mass Data: ", DecodedData)
--Extra stuff down here that I dont think would be relevant currently