Instances as Table Keys changing format

The keys in my scripts keep changing format, and I’m unable to do a if statement to check them since they don’t register as the same.

--server script
local movesicanmake = nil

-- i do other things to fill it with values, then fire it to the client
print(movesicanmake)
Move:FireClient(playerwhosmove, movesicanmake)

--client script
local function MakeMove(tableofmoves)
   -- I do other things here, but for the sake of simplicity I'll leave the 
   --important part
   print(tableofmoves)
end
Move.OnClientEvent:Connect(MakeMove)

--the server script print statement outputs this-
   ▼  {
                    [Instance(26BA8436148)] =  ▶ {...},
                    [Instance(26BD1E2CDA8)] =  ▶ {...}
                 }  
--the client one outputs this-
  ▼  {
                    [" (Black9)"] =  ▶ {...},
                    [" (White6)"] =  ▶ {...}
                 } 

I don’t know what changed. Also later on in the same client script I loop through instances in the workspace and save it in the same format, and it outputs in the weird format again.

local oldlocation = nil
local Players = game:GetService("Players")
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()

local function selectmove()
	local Item = Mouse.Target
	for i5,v5 in pairs(game.Workspace.Tiles:GetChildren()) do
		if v5.Name == Item.Name then
			oldlocation = Item["Original Location"].Value --this is unimportant
			for i2, v2 in pairs(game.Workspace.Tiles:GetChildren()) do
				if v2.Name == oldlocation then
					oldlocation = v2
					local Move = {}
					Move[oldlocation] = {v5}
					print(Move)
					--this is where I'd send it to the server for 
					--validation, but  I can't check it since  when i send
					-- it to the server, it switches format again
					
				end
			end
		end
	end
end
Mouse.Button1Up:Connect(selectmove)
-- This is what it outputs-
  ▼  {
                    [Instance(26BD3482658)] =  ▶ {...}
                 }  
3 Likes

This is documented behaviour, not a bug at your side:

Non-String Indices

If any indices of a passed table are non-string type ( Instance , userdata, function, another table, etc.), those indices will be converted to a string

Consider packing the instances with their tables as such:

{
    {"Instance"= instance1, "info": table1},
    {"Instance"= instance2, "info": table2}
}
3 Likes