Hi. This limits the CFrame orientation of “Part”. I’m trying to find a way to limit the rotation and have part look towards “Target”.
local RunService = game:GetService('RunService')
local Part = workspace.Part
local Target = workspace.Target
RunService.Stepped:Connect(function()
local x,y,z = Part.CFrame:ToOrientation()
local xClamp = math.clamp(math.deg(x), -45, 45)
local yClamp = math.clamp(math.deg(y), -45, 45)
local zClamp = math.clamp(math.deg(z), -45, 45)
Part.CFrame = CFrame.new(Part.CFrame.p) * CFrame.fromOrientation(
math.rad(xClamp),
math.rad(yClamp),
math.rad(zClamp)
)
--Part.CFrame = CFrame.new(Part.Position,Target.Position) but follow limitations.
end)