How to make a minimap from a image label?

Hello, I am making a minimap utilizing viewport frames, and on a smallscale test map, what I have made works extremely well, utilizing RoRender and viewport frames, however I want to use this on a large map

Here is the size of the map. The gray plane is the entire size of the map, the blue outer ring is the sky, and the inner blue box is the maximum size you can resize a part. The gray plane is made out of multiple parts, and I want to apply this image of the map I have rendered onto said plane.

How would I go about doing this? Thank

1 Like

There are two ways that I can think of, you could try just dividing the original image into sections based on the number of parts in the grey plane and uploading them as individual decals. Alternatively, a better method I think would be to use a texture on each of the parts and do some sort of maths to determine how much offset to apply based on the number of rows/columns around the part.

Edit: Came back with some maths that might work? It’s based off an old gif player that used a single spritesheet on a texture. It’s a bit rushed so I might come back and polish it/make it easier to use if I get the chance.

-- Credits: bobbybob2131
-- Last edited: 26 July 2022
-- Description: Scales a texture over multiple parts

Each part should have an XIndex and YIndex attribute to determine it's relative position.

local NUM_ROWS = 5 -- Include overflow row (incomplete row)
local NUM_COLUMNS = 5
local HOLDER = script.Parent.Parent -- Part with the texture on
local LINEAR_SPRITESHEET = false -- Linear spritesheets (only one row/column)
local LINEAR_DIRECTION = "X" -- "X" or "Y" determines if it is a horizontal/vertical strip
local TEXTURE = nil -- ID/Texture Instance/ID string - defaults to first texture child

local size = HOLDER.Size
local holderXIndex = HOLDER:GetAttribute("XIndex") or 1
local holderYIndex = HOLDER:GetAttribute("YIndex") or 1
local texture

if TEXTURE then
	if typeof(TEXTURE) == "number" then
		texture ="Texture")
		texture.Texture = tostring(TEXTURE)
		texture.Parent = HOLDER
	elseif typeof(TEXTURE) == "string" then
		texture ="Texture")
		texture.Texture = string.match(TEXTURE, "%d+") :: string
		texture.Parent = HOLDER
	elseif TEXTURE:IsA("Texture") then
		texture = TEXTURE
	texture = HOLDER:FindFirstChildOfClass("Texture")

local face = texture.Face

local pseudoX
local pseudoY

-- May require tweaks, just done off the top of my head
if face == Enum.NormalId.Front or Enum.NormalId.Back then
	pseudoX = "X"
	pseudoY = "Y"
elseif face == Enum.NormalId.Top or Enum.NormalId.Bottom then
	pseudoX = "X"
	pseudoY = "Z"
	pseudoX = "Y"
	pseudoY = "Z"
local xSize = size[pseudoX]
local ySize = size[pseudoY]

texture.StudsPerTileU = NUM_COLUMNS * xSize
texture.StudsPerTileV = NUM_ROWS * ySize

	if LINEAR_DIRECTION == "X" then
		texture.OffsetStudsU += xSize * holderXIndex
		texture.OffsetStudsV += ySize * holderYIndex
	texture.OffsetStudsU = xSize * (holderXIndex - 1)
	texture.OffsetStudsV = ySize * (holderYIndex - 1)

Instead of making the viewport map larger, i would just translate the player position into the viewport with some math. Im pretty sure you would just need to multiply the players position by the ratio of the viewport map size/ real map size.

1 Like

I was thinking about doing this by adding a surface gui on each grid piece to get its AbsoluteSize, then cutting out pieces based on that, but im not sure how i would make it as accurate as it can be. Ill try this out first and if it doesnt work ill try out maths like you pointed out

edit: that crashed my pc. How do i use the code you made? where would i parent the script

Would that mean that i should reduce the size of the viewport map, by lets say 10x, then ill multiply by 10 to get the position of where the player is?

Update. I was searching around and figured it would be better to use an imagelabel and reflect the players position on there relative to an origin point. I am still confused on how I would manage to do this, does anyone know of a way?