Here is all my relevant code. I have an object on the table that I use its GUID then when the table loads I set the variable TargetLock to be that GUID and myShip is a variable that I use often and is set by the sync function. This connects my board and a ship figureain and everything works as it should. I can clone all my tokens but just for this one, I want to change its name and color for one in particutilar.

Code:

TargetLockGUID = 'e8bea7'
function onLoad()
--Make a button with the 'click_function = 'click_TargetLock''
TargetLock = getObjectFromGUID(TargetLockGUID)
end
function click_Sync ()
print("**---Locating Ship---**")
--look for all object class items on the table
local allObjects = getAllObjects()
local foundFigurine = false
for _, object in ipairs(allObjects) do
--only look for figurine's
if object.tag == "Figurine" then
--Locate the distance to all objects
local distance = findProximity(self.getPosition(), object)
--Here is the check for distance
if distance <= 2 then
-- Get the current name of the panel
objectName = object.getName()
self.setName(objectName)
linkShip_GUID = object.getGUID()
print(object.getName() .. " found.")
foundFigurine = true
end
end
end
if foundFigurine == false then
print("No ship found, place ship on this card")
end
print("**-------------------------**")
myShip = getObjectFromGUID(linkShip_GUID)
myShip.createButton({function_owner=self,click_function = 'click_FindRange',label = 'Ø',position = {0,0.3,0},width =225,height =225,font_size =200})
end
--Used by click_Sync
function findProximity(targetPos, object)
local objectPos = object.getPosition()
local xDistance = math.abs(targetPos.x - objectPos.x)
local zDistance = math.abs(targetPos.z - objectPos.z)
local distance = xDistance^2 + zDistance^2
return math.sqrt(distance)
end
myShip = {}
function click_TargetLock(obj, playerColor)
local pos = myShip.getPosition()
local angle = myShip.getRotation()
local forward = 1.1
local side = 0
local forX= math.sin(math.rad(angle.y))*forward
local forZ= math.cos(math.rad(angle.y))*forward
local sideX= math.sin(math.rad(angle.y+90))*side
local sideZ= math.cos(math.rad(angle.y+90))*side
local newLock = TargetLock.clone ({
position = {pos.x-forX-sideX, pos.y+1, pos.z-sideZ-forZ}
})
shipName = myShip.getName()
print(shipName)
newLock.setName(shipName)
newLock.setColorTint(stringColorToRGB(playerColor))
end