How to pass an instance through remote event

So i am making a game, and one thing in this game is a sliding puzzle type minigame. So each of the tiles have the attributes xcord, ycord and number and i want to pass the instance (the selected tile) through from a server script into a local script so i can move the tile. But it is simply just not working.

Ive tried everything and this seems to me like it should be working but i don’t know whats going on

--server script
for _,v in ipairs(puzgrid:GetChildren()) do
	if v:IsA("Part") then
		v.ClickDetector.MouseClick:Connect(function()
			replistore.tileselect:FireAllClients(v)
		end)
	end
end

--client script
tile = replistore.tileselect.OnClientEvent:Connect(function(v)
	print('number is:',v:GetAttribute('ycord'))
	ss["Audio/Roblox_Pinball_Small_Button_Press_11"]:Play()
	return v
end)

currentx = tile:GetAttribute('xcord')
currenty = tile:GetAttribute('ycord')
currentnum = tile:GetAttribute('numbers')
1 Like

Return will not work here as tile holds the RBXScriptConnection. I suggest you do something like this:

local tile
replistore.tileselect.OnClientEvent:Connect(function(v)
	print('number is:',v:GetAttribute('ycord'))
	ss["Audio/Roblox_Pinball_Small_Button_Press_11"]:Play()
	tile = v
    currentx = tile:GetAttribute('xcord')
    currenty = tile:GetAttribute('ycord')
    currentnum = tile:GetAttribute('numbers')
end)

This depends on if you are going to use tile outside of the connection, if not you can just use v