How to keep the original position when changing the anchor point?

local Map = {}

local function SetAnchorPoint(Gui, DesiredAnchor)
	print("fired")
	local Canvas = Gui.Parent -- Object's Parent GUI (AbsoluteSize needed for Scaling.)
	local ParentSize = Canvas.AbsoluteSize
	-- tada:
	local ParentPosition = Canvas.AbsolutePosition
	local ChildSize = Gui.AbsoluteSize
	local ChildPosition = Gui.AbsolutePosition
	-- tada:
	ChildPosition = ChildPosition - ParentPosition

	local CorrectionOffsetX = ChildSize.X * DesiredAnchor.X
	local CorrectionOffsetY = ChildSize.Y * DesiredAnchor.Y

	local CorrectedUDim2 = UDim2.fromScale((ChildPosition.X + CorrectionOffsetX) / ParentSize.X, (ChildPosition.Y + CorrectionOffsetY) / ParentSize.Y)
	Gui.AnchorPoint = DesiredAnchor
	Gui.Position = CorrectedUDim2
	print(CorrectedUDim2)
end

function Map.MoveMouseAnchor(Map, Mouse)
	local DesiredAnchr = Vector2.new(Mouse.X / 1000, Mouse.Y / 1000)
	SetAnchorPoint(Map, DesiredAnchr)
end


return Map

I’m trying to achomplish a similar thing and move the anchorpoint to the mouse position. the GUI does not remain in its spot.