Where would I start to making Minimap markers?

Im trying to create a miniMap that displays a textlabel based on where doors that can be opened are, sort of like Lethal Companys terminal display.

Im running into an issue in which I dont fully understand how to make the textLabels position match the doors position.

Here is what i am current using to determine the doors:

local function map(n, start, stop, newStart, newStop)
	local value = ((n - start) / (stop - start)) * (newStop - newStart) + newStart
	if newStart < newStop then
		return math.clamp(value, newStart, newStop)
	else
		return math.clamp(value, newStop, newStart)
	end
end

local function CloneMinimapObjects(parentFolder)
	local clonedObjects = {}
	for _, object in ipairs(parentFolder:GetChildren()) do
		if object:IsA("Folder") then
			CloneMinimapObjects(object)
		elseif object.Name ~= "Roof" then
			if (object:IsA("Model") and (object.Name == "KeycardDoubleDoor" or object.Name == "KeycardSingleDoor")) then
				clone = TemplateFrame:Clone()
				local doorId = object:GetAttribute("DoorId")
				print(doorId)
				clone.Name = doorId or "Unknown"
				clone.DoorId.Text = doorId or "Unknown"
				clone.Parent = ViewportFrame
				RunService.RenderStepped:Connect(function()
					if object.PrimaryPart ~= nil then
						local objectPosition = object.PrimaryPart.Position
						local x = map(objectPosition.X, -1000, 1000, -ViewportFrame.AbsoluteSize.X / 2, ViewportFrame.AbsoluteSize.X / 2)
						local y = map(objectPosition.Z, -1000, 1000, -ViewportFrame.AbsoluteSize.Y / 2, ViewportFrame.AbsoluteSize.Y / 2)
						clone.Position = UDim2.new(0.5, x, 0.5, y)
					else
						return
					end
				end)
				model = object
				table.insert(clonedObjects, clone)
			else
				local clone = object:Clone()
				clone.Parent = ViewportFrame
				table.insert(clonedObjects, clone)
			end
		else
			local clone = object:Clone()
			clone.Parent = ViewportFrame
			table.insert(clonedObjects, clone)
		end
	end
	return clonedObjects
end

Basically what this script does is clone anything in my Map Folder and puts it in my Viewport to display while also identifying the doorsId values and cloning the marker into my frame. So far this doesnt work and im not sure why, might be because im not that great at math but, all help is appreciated!

1 Like

Not sure about the specifics of how your code interacts with the workspace or what it looks like currently, but couldn’t you create a textlabel and place it on a surface gui in front of the door, then use events to trigger if it’s visible or not?

Not exactly, Im trying to make it appear on the viewportFrame like this.
image

I believe that Surface Guis wouldnt work in this situation

Hi! I believe they could possibly work. create a part, give whatever Gui needed then aim it to the sky, using something like the following:

door.CFrame  = CFrame.new(Vector3.new(door.Position.X,50,door.Position.Z), Vector3.new(door.Position.X,9999,door.Position.Z))

Personally, I would normalize the image GUI’s in reference to it’s distance from the angle your map is looking from. There might be some pixelation, but it should still be negligible

If you dont want to do this method, then the math involved with creating an accurate minimap would probably using RunService to constantly measure the X and Z distances between a door and displaying it based on the ratios you tested. Let me know if you need help with the math part, but im pretty sure you got it!