Rotating a minimap based on camera rotation

I’d like to rotate a minimap I’ve created based on the player’s camera rotation - so if they rotate their camera, the minimap does too.

Current code:

local Player = game.Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()

if Character.Parent == nil then

Character.AnscestryChanged:Wait()

end

local Root = Character:WaitForChild("HumanoidRootPart")

local CurrentCam = game.Workspace.CurrentCamera

local MinimapObjects = game.Workspace:WaitForChild("MinimapObjects")

local MinimapViewport = script.Parent:WaitForChild("ViewportFrame")

local RunService = game:GetService("RunService")

function SetCamCFrame(Cam)

local CF = CFrame.new(Root.Position + Vector3.new(0, 5000, 0), Root.Position) * CFrame.Angles(0, 0, 0)

Cam.CFrame = CF

end

local Cam = Instance.new("Camera")

SetCamCFrame(Cam)

Cam.FieldOfView = 1 -- makes it orthographic/flat/2d

Cam.CameraType = Enum.CameraType.Scriptable

Cam.Parent = game.Workspace:WaitForChild("CamPart")

MinimapViewport.CurrentCamera = Cam

for i, v in pairs(MinimapObjects:GetChildren()) do

v:Clone().Parent = MinimapViewport

end

RunService.RenderStepped:Connect(function()

SetCamCFrame(Cam)

end)

Currently I don’t really know how I’d rotate the minimap properly, an in depth description of how to would be useful (ofc don’t write the whole code for me lol)

You can get the facing direction of a part (or in this case, a player character’s head) using a CFrame’s LookVector, then from there, maybe create a tween or something to rotate the minimap facing the lookvector.

Yeah, but IDK the math for it.