RemoteFunction: "keys must be strings"

Invoke a remote function from a localscript without parameters, like so:

result = remotefunction:InvokeServer() 

Occasionally it will error on that line, printing “keys must be strings” in the output as an error.

I’ve come across this error twice today. Today (as in, 30 minutes ago) was the first time I’ve seen it, and it has happened a few times since. The error appears to occur randomly. I haven’t been able to provoke the error - sometimes it happens, sometimes it doesn’t.

Anyone know what this is?

I’ve went through this error before. It errors because you’re trying to pass a table with keys that are not string/number. Ex:

remoteFunction.OnServerInvoke = function(player,...) return {[player] = {}} end

That’s weird.
I’m returning a tabe, but all keys should be numbers or strings. Unless I’ve majorly messed something up.
I’ll check again, but there should be no reason for this to be happening…

EDIT: I’ve checked, all my keys are either of the number or string type.

Could having a Vector3 in the table cause this issue?

 return { vec = Vector3.new(1,2,3) } 

I’m not sure how it handles these, and I started getting this error after I started attempting to transfer Vector3s.

[quote] That’s weird.
I’m returning a tabe, but all keys should be numbers or strings. Unless I’ve majorly messed something up.
I’ll check again, but there should be no reason for this to be happening…

EDIT: I’ve checked, all my keys are either of the number or string type.

Could having a Vector3 in the table cause this issue?

 return { vec = Vector3.new(1,2,3) } 

I’m not sure how it handles these, and I started getting this error after I started attempting to transfer Vector3s. [/quote]Yeah, I think like DataStores, RemoteFunctions/RemoteEvents don’t like userdata values either.

Try sending the Vector3 as a table with three numbers, and then convert that from the other side to a Vector3.

I have now made sure that there are no userdata values in the tables. There are only numbers, strings and other tables in the table I return. I still get the error.

I’m going to attempt to work around this by using pcall and retrying until a result is achieved. That should work - in the mean time, I’d be happy if someone could look into fixing this issue.

EDIT: My workaround fails. It appears that once the error occurs, it’s there to stay.

Can you print the table contents once pcall returns false and post it here?

Btw, Vector3 should work. Here’s a test we use that lists all supported primitive values:

-- Verify serialization of various objects
local sres = workspace.FunctionSerialize:InvokeClient(player1,
	true,
	2,
	1.5,
	"test",
	BrickColor.new("Black"),
	{ foo="bar" },
	Vector3.new(1, 2, 3),
	Vector2.new(1, 2),
	Vector3int16.new(1, 2, 3),
	Vector2int16.new(1, 2),
	Color3.new(1, 0.5, 0.25),
	CFrame.new(1, 0.5, 0.25),
	Ray.new(Vector3.new(1, 2, 3), Vector3.new(0, -1, 0)),
	UDim.new(1, 2),
	UDim2.new(1, 2, 3, 4),
	Axes.new(Enum.Axis.X, Enum.Axis.Y, Enum.Axis.Z),
	Faces.new(Enum.NormalId.Right),
	Region3.new(Vector3.new(1, 2, 3), Vector3.new(4, 5, 6)),
	Region3int16.new(Vector3int16.new(1, 2, 3), Vector3int16.new(4, 5, 6)),
	workspace.BasePlate,
	{},
	""
	)

The only known limitations are: