Help with minimap

I’m making a minimap, and the rotation is broken:

Going forwards it looks fine,
Every other direction is broken.

I’m using a viewport frame that clones the map.

Code that controls the Viewport Camera:

RunService.RenderStepped:Connect(function()
	camera.CFrame = CFrame.lookAt(root.Position+Vector3.new(0,500,0),root.Position)*CFrame.Angles(0,math.rad(45),math.rad(root.Orientation.Y))
end)

what are you using to display the minimap? i think you should rotate the viewportframe( if you are using it or the frame) rather than the camera

I would suggest just setting the camera CFrame to something like this:

Camera.CFrame = CFrame.LookAt(root.Position+(root.CFrame.LookVector*-200 )+ (root.CFrame.UpVector*500), root.Position)

Sets the camera position 200 studs behind the root and 500 studs up, then points towards it

It sounds like you’re trying to create a minimap using a viewport frame, but the rotation is not working correctly. Your code snippet suggests that you’re trying to adjust the camera.CFrame to look at a specific position while considering the orientation of the root object. However, it seems there might be an issue with how you’re calculating the rotation.

If your goal is to create a top-down minimap that follows the player’s root orientation, you can adjust the rotation using the player’s orientation in the X-Z plane (yaw). Here’s how you might modify your code:

luaCopy code

local RunService = game:GetService("RunService")
local player = game.Players.LocalPlayer
local camera = script.Parent.ViewportFrame.Camera
local root = player.Character:WaitForChild("HumanoidRootPart")

RunService.RenderStepped:Connect(function()
	local yaw = math.rad(root.Orientation.Y) -- Convert to radians
	camera.CFrame = CFrame.lookAt(root.Position + Vector3.new(0, 500, 0), root.Position) * CFrame.Angles(0, yaw, 0)
end)

In this code, I’ve assumed that you want to capture the rotation around the Y-axis (yaw) of the player’s root part and apply it to the minimap camera. The CFrame.Angles(0, yaw, 0) part handles this rotation.

Make sure that the root part of the player’s character is correctly named “HumanoidRootPart,” and ensure that the player’s character is loaded and present in the game before using it.

Keep in mind that this code snippet only addresses the rotation issue you mentioned. You might need to adjust other aspects of your minimap code to ensure it functions correctly and follows the player’s movement and orientation accurately.

I think u are trying to do a 3D effect, I think make the camera rotate and don’t rotate the GUI.

i don’t know if its that simple tho again coding is complex

You can’t angle it downwards at all.

I am making the camera rotate. It just is working how I expected, not even after a bunch of tested.