Remote Function Bug?

So recently, my dictionary that I’m sending over with a remote function from:
(call) local → (calculate) server → (send back) local
converts my vector2 into strings

So for example, a table like this

local myTable = {
    [vector2.new(-1,1)] = 0
}
--[[  When printing it looks something like this below
because that's how it displays in the console normally ]]
[Vector2(18D6C1A3040)] = 0,

would be converted into this

["<Vector2> (-1, 1)"] = 0,

which isn’t even like the tostring(vector) version which would return “-1, 1” instead of whatever’s above

I am not sure if this is intentional or a bug, so I’m just going to go ahead and report it just in case

3 Likes

thats intentional “bug” same thing happens when you store Instances as index inside of table

example code that proves this theory:

game:GetService("Players").PlayerAdded:Wait()

local Players=game:GetService("Players"):GetPlayers()
local players1={[Players[1]]="test"}

print(players1)
2 Likes

maybe move this to Scripting Support because devforum staff will get angry at you

2 Likes

not really? It’s still the same
Console just prints it’s address in memory

if you do

for n, c in pairs(players1) do
	print(n, c, type(n))
end

right after. The 3rd param in the print inside the for loop will print userdata (aka not a string)

I’m talking about sending a dictionary value through a remote function and it actually changing into a string

here you can try it yourself

Local Script

local button = script.Parent.t -- Button to just activate local
local rmf = game.Workspace.scriptTest.RemoteFunction -- Remote Function

button.MouseButton1Down:Connect(function()
	local r = rmf:InvokeServer()
	for n, v in pairs(r) do
		print(n,v,type(n))
	end
end)

Server Script

script.RemoteFunction.OnServerInvoke = function()
	return {
		[Vector2.new(2,3)] = 2,
		[Vector2.new(8,0)] = 1
	}
end

Console Results:

  14:31:27.941  <Vector2> (8, 0) 1 string  -  Client - LocalScript:8
  14:31:27.941  <Vector2> (2, 3) 2 string  -  Client - LocalScript:8

The documentation states

If any indices of a passed table are non-string types such as an Instance, userdata, or function, Roblox automatically converts those indices to strings.

https://create.roblox.com/docs/scripting/events/remote#non-string-indices

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.