ViewportFrame Minimap w/ Singular Imaged Part (Help)

I have been trying to make a minimap lately that doesn’t need to have multiple duplicated objects of the map in the viewportFrame or the script being too complicated.

So I decided to make a singular part that contains an image of the map. This image moves along with the player based on its relative position of the map’s center, but I haven’t been able to correlate it well. I’ve been trying to tweak things but I just assume the whole code is a mess. The map moves perfectly once the character moves, but if you move the camera, the whole minimap goes crazy. (Not only that, but the position of the player in the minimap isn’t the same as in the real game world)

Code:
abaf7406-5a3d-4436-8c6e-c02fd6082027

Minimap problem:
307582bb9e1dc0c85a91c9806fb67081

Note: The Part is Vertical, therefore the “Z” axis in-game would be the “Y” axis for the part to show in the minimap. The “/8” has been put there just to test things, back then I had it at “/2” for my test map, but my test map was smaller than this one.

Hope you can help me, if you need more details, please ask right away! Have a great day.

I still don’t know if there’s a better way of doing this, I’m most definitely doing something wrong.

What camera is the viewport frame set to? If the player camera is affecting it, then you should create a new camera with a set cframe.

The camera is a default one, I have not added a new camera or edited the camera at all for the viewport.

Since the minimap isnt meant to rotate with the player, try making a seperate camera, that way the player can’t affect it by looking around.

The minimap is meant to rotate with the player

edit: the thing is that it’s rotating wrong

Technically it moves while you move the camera, making it seem like it’s rotating, but I don’t want this unnecessary moving when you move the camera

Are you looking for the map part to rotate, or the arrow in the center? You can’t have both rotate so im a little confused on your goal. If you dont want the map part to rotate then create a new camera. If not, then that is a different problem in itself.

Ok, so the cursor and the map will rotate at the same time, and the map will move around opposite to the character’s movement. The map can rotate by using the Orientation property and setting it similar to the character’s HumanoidRootPart Rotation, the problem that I’m having is that the map, just because of how I set it to use the “ToObjectSpace” moves the map by a lot just once the HumanoidRootPart rotates, although I don’t want it to move once character rotates but once it moves. It is capable of achieving the movement part but breaks only if the character rotates.

Nevermind, now I know, that won’t be possible… Let me re-think how I’m going to do this.

I kind of did what you told me to do, but without a camera. I removed the map rotation, and left it still, although I changed the way of moving the map:

It consists of look vectors for the mouse rotation, making it much more accurate, and dividing the character’s position by the scaled-down map in the viewportFrame. The key was the division, I did a (worldSize.X / mapSize.X) + (worldSize.Z/mapSize.Y) to get a singular number that works as the “ratio” of the sizing. It’s kind of like scaling down the big map to a small map.

This idea I took from this post and code by AnAbsurdlyLongName and edited a few things, as well contributed my own conception of getting an accurate number based on the world’s size and map’s size.

Note: You’ll have to tweak the miniMap’s part size relative to the map’s size for this to work.