Error within finding angle between 2 vectors

So I’ve been searching around and found a way to determine angle between 1 vector and 2nd vector but I can’t seem to either correctly use it or apply it, I am attempting to get the angle between your torso and a flying brick which then the script calculates the angle and through modifying the WaistConstraint will rotate your torso to the needed angle to generally look at the brick

local CameraLookVector = RotateTo.Position
local HeadLookVector = plr.Character[WeaponName].Barrel.Position

Remotes.ReadyToRotate:FireClient(plr, math.acos( CameraLookVector:Dot(HeadLookVector)/(CameraLookVector.Magnitude * HeadLookVector.Magnitude)))
Remotes.Rotate.OnServerEvent:Connect(function(plr, theta, Target)
	print("Activated")
	local waistC0 = CFrame.new(0, 0.2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
	local waist = plr.Character.UpperTorso.Waist
	print(theta)
	waist.C0 = waistC0 * CFrame.fromEulerAnglesXYZ(theta, 0, 0)
	wait(6)
	waist.C0 = waistC0
end)

When applied my character most of the time just rotates to completely different angle that proposed

You can use this code for reference. Put it in a LocalScript in StarterCharacterScripts and look at how the waist behaves

local Part = Instance.new("Part", workspace)
Part.Anchored = true
Part.CanCollide = false

local RunService = game:GetService'RunService'
local Players = game:GetService'Players'
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character
local RootPart = Character.HumanoidRootPart
local Waist = Character.UpperTorso:WaitForChild'Waist'
local WaistC0 = CFrame.new(0, 0.2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)

RunService.Stepped:Connect(function()
	Part.CFrame = CFrame.new(math.sin(tick()) * 10, 1, -5)
	
	local A = -RootPart.CFrame.LookVector
	local B = RootPart.Position - Vector3.new(Part.Position.X, RootPart.Position.Y, Part.Position.Z)
	local Angle = A:Cross(B.Unit).Y
	
	Waist.C0 = WaistC0 * CFrame.Angles(0, Angle, 0)
end)

local CameraLookVector = RotateTo.Position
local HeadLookVector = plr.Character[WeaponName].Barrel.Position

The script fails because the variables aren’t what the names suggest they are at all. Neither of these are look vectors, or even relative to anything. They are both absolute positions in the world. Your script is trying to find the angle between RotateTo, the center of the world (0, 0, 0) and a gun’s barrel, which will give you nonsense regardless of what you do with them.
Garbage data in, garbage data out.

the angle between your torso and a flying brick

By “the torso” I assume you mean the front facing of the torso.
So the torso direction would be torso.LookVector. It is a vector that points in the same direction as the front surface of the torso, and has a length of 1.
And the flying brick’s position would have to be relative to the torso’s position just like that lookvector, otherwise it will be nonsense. That’s brick.Position - torso.Position. It has an unknown length, but the part with the Magnitudes at the end fixes it up anyway.

local TorsoFacing = Torso.LookVector
local HeadLookVector = plr.Character[WeaponName].Barrel.Position - Torso.Position

You also have to eliminate the y axis of these, so that you don’t get the torso rotating more than normal if the object is high above or low below the torso’s position.
Otherwise it tries measuring the angle between the objects - which isn’t always horizontal - and then rotates the torzo horizontally (i.e. not on the same axis)

local TorsoFacing = Torso.LookVector * Vector3.new(1, 0, 1)
local HeadLookVector = plr.Character[WeaponName].Barrel.Position - Torso.Position * Vector3.new(1, 0, 1)

Why would I need to get rid of Y axis if I’m trying to make UpperTorso face the right angle on the Y axis

image