How can I adjust this for my needs?

I have this minimap script, it works, however it does so ONLY if the minimap viewport frame X and Y sizes are the same, otherwise the parts aren’t shown where they actually are in the workspace. I want to fix that

code:

local Minimap = script.Parent:WaitForChild("Minimap")
local Arrow = Minimap:WaitForChild("Arrow")

local IconsFolder = game.Workspace:WaitForChild("Icons")

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

local Camera = Instance.new("Camera")
Camera.FieldOfView = 1
Camera.CameraType = Enum.CameraType.Scriptable
Camera.Parent = game.Workspace
Minimap.CurrentCamera = Camera

task.wait(2)


local function isPartFromCharacter(part)
	return part:IsDescendantOf(Character)
end


for i, Object in pairs(game.Workspace:GetDescendants()) do
	if isPartFromCharacter(Object) then
		continue 
	end
	if Object:IsA("Terrain") or not Object:IsA("BasePart") then
		continue 
	end
	Object:Clone().Parent = Minimap
end


for i, child in pairs(game.Workspace.Icons:GetChildren()) do


	local W2VP

	W2VP = Camera:WorldToViewportPoint(child.Position)
	local TextClone = script.Parent.Parent.TextLabel:Clone()
	TextClone.Text = child.Name
	TextClone.Name = child.Name.."GUI"
	TextClone.Position = UDim2.new(W2VP.X, 0, W2VP.Y, 0)
	TextClone.Parent = game.Players.LocalPlayer.PlayerGui.MinimapGui.Minimap
	TextClone.BackgroundTransparency = 1


end

function add()
	for i, child in pairs(game.Workspace.Icons:GetChildren()) do
		local W2VP = Camera:WorldToViewportPoint(child.Position)
		game.Players.LocalPlayer.PlayerGui.MinimapGui.Minimap:FindFirstChild(child.Name.."GUI").Position  =  UDim2.new(W2VP.X, 0, W2VP.Y, 0)

	end
end

function characterIcon()
	local W2VP = Camera:WorldToViewportPoint(Player.Character.HumanoidRootPart.Position)

	W2VP = Camera:WorldToViewportPoint(Player.Character.HumanoidRootPart.Position)
	game.Players.LocalPlayer.PlayerGui.MinimapGui.Minimap.Arrow.Position = UDim2.new(W2VP.X, 0, W2VP.Y, 0)
	
	
end


game:GetService("RunService").RenderStepped:Connect(function()
	--local camCFrame = CFrame.new(HumanoidRootPart.Position + Vector3.new(0, 10000, 0), HumanoidRootPart.Position)
	local camCFrame = CFrame.new(game.Workspace.Baseplate.Position + Vector3.new(0, 10000, 0), game.Workspace.Baseplate.Position)
	Camera.CFrame = camCFrame
	Arrow.Rotation = - HumanoidRootPart.Orientation.Y - 90
	add()
	characterIcon()
end)