Needing help transposing a Vector3 to Udim2 function

Hey what’s up,

so I’ve been running my head into a wall trying to figure out how to sort this out.

Essentially I’ve made a map system similar to the game squad, where it uses a pre-rorendered map and then allows players to see their location and what not, I’ve gotten vector 3 values translated to udim2 for the ui, however i’m running into an issue of where I’m unsure of how to reverse it so I my map markings, map tool actually work…

Code + Preview:
local mapcfg = {
	Bounds1 = Vector3.new(8250, 0, 7050), 		 -- Positive Point
	Bounds2 = Vector3.new(3750, 0, 2550),		 -- Negative Point
	
	pratio = 0.4, 					 			 -- Pixels per stud,
	res = {1800, 1800},				 -- size of map img (max roblox size is 1000x1000 so if map is larger, split into quarters, top left, top right, etc)
	
}

local LengthX = mapcfg.Bounds1.X - mapcfg.Bounds2.X
local LengthZ = mapcfg.Bounds1.Z - mapcfg.Bounds2.Z

function TranslateMarkerToUI(pos : Vector3)
	local px1 = (pos.X - mapcfg.Bounds2.X) / LengthX
	local pz1 = (pos.Z - mapcfg.Bounds2.Z) / LengthZ

	local XOffsetTest = ((0.5 - px1) * 10) * (zoom/100)
	local ZOffsetTest = ((0.5 - pz1) * 10) * (zoom/100) 

	local positiontoreturn = UDim2.new(((x/mapcfg.res[1])+px1 - XOffsetTest), 0, ((z/mapcfg.res[2])+pz1 - ZOffsetTest), 0)
	return positiontoreturn
end

p3EZOZVO

I’ve tried chatgpt and roblox’s integrated AI and asked a few friends, but to no avail am I able to come to a solution.

Hopefully theres some smarter individuals out there who have a clue,
Anyways thanks,
xg