How can i properly attach the player's Y camera axis to an viewport camera

This is my script that i’m using

local screenGui = script.Parent
local minimapFrame = screenGui:WaitForChild("Minimap")
local directionArrow = minimapFrame:WaitForChild("DirectionArrow")


local plr = game.Players.LocalPlayer

local char = plr.Character or plr.CharacterAdded:Wait()

local hrp = char:WaitForChild("HumanoidRootPart")
local humanoid = char:WaitForChild("Humanoid")


local currentCamera = Instance.new("Camera")

currentCamera.FieldOfView = 60
currentCamera.CameraType = Enum.CameraType.Attach
currentCamera.CameraSubject = hrp
currentCamera.Parent = workspace


minimapFrame.CurrentCamera = currentCamera


for i, minimapObject in pairs(workspace.MinimapObjects:GetChildren()) do

	minimapObject:Clone().Parent = minimapFrame
end

game:GetService("RunService").RenderStepped:Connect(function()
	local camcframe = workspace.Camera.CFrame
	local camrot = CFrame.Angles(0, hrp.Rotation.Y,0)
	local camCFrame = CFrame.new(hrp.Position + Vector3.new(50, 25, 0), hrp.Position) * camrot
	currentCamera.CFrame = camCFrame
	
	
	directionArrow.Rotation = -hrp.Orientation.Y + 90
end)

The script makes the viewport camera go nuts, and it don’t rotate in Y axis at all, it rotates but it’s a mess

A video showing the problem: Microsoft OneDrive - Access files anywhere. Create docs with free Office Online.
i tried everything i know to make this work

CFrame.Angles() accepts radians, not degrees.

CFrame.Angles(0, math.rad(hrp.Rotation.Y), 0)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.