I’m using an angle clamp for normals using cframe.matrix, but it doesn’t work, my knowledge points to the rightvector
local Part1 = workspace.Part1
local Part2 = Part1:Clone()
Part2.Parent = workspace
Part2.Name = "Part2"
Part2.Color = Color3.fromRGB(255,0,0)
Part2.Transparency = 0
local Part3 = Part1:Clone()
Part3.Parent = workspace
Part3.Name = "Part2"
Part3.Color = Color3.fromRGB(38, 255, 0)
Part3.Transparency = 0
Part3.Size = Vector3.new(1,1,5)
function clamp_vector_angle(vector,min,max)
local _view = CFrame.new(Vector3.new(),vector)
local rX, rY, rZ = _view:ToOrientation()
local limX = math.rad(math.clamp(math.deg(rX),min,max))
local limY = rY
local limZ = rZ
local new_vector = CFrame.new() * CFrame.fromOrientation(limX,limY,limZ)
Part3.CFrame = CFrame.new(Part1.CFrame.p)*new_vector
Part3.CFrame += Vector3.new(0,10,0)
return Part3.CFrame
end
while wait() do
local RightVector = Part1.CFrame.RightVector
local upVector = Part1.CFrame.UpVector
local ClampedUpVector = clamp_vector_angle(upVector,50,90)
upVector = ClampedUpVector.LookVector
RightVector = ClampedUpVector.UpVector -- Here's the problem
local newFacialVector = RightVector:Cross(upVector)
--local newFacialVector_Dot = currentLookVector_Root:Dot(upVector)
Part2.CFrame = CFrame.fromMatrix(Part1.CFrame.p, RightVector,upVector, newFacialVector)
Part2.CFrame += Vector3.new(0,10,0)
end
