you can do some vector math using the frames 'AbsolutePosition' property and the parents 'AbsolutePosition' property. Basicly, you're gonna need the difference between those vector so just subtract the frames absPos from the parents absPos and you have what the canvasPosition should be:
local frame = script.Parent.Frame
local canvas = script.Parent
local function getCanvasPosition(Frame)
local differenceVector = canvas.AbsolutePosition - Frame.AbsolutePosition
return UDim2.new(0, differenceVector.X, 0, differenceVector.Y)
end
canvas.CanvasPosition = getCanvasPosition(frame)