Limiting Rotation

I’m making a turret that points towards the players mouse, but I’m not sure how I would make limitations on the rotating. I don’t want them to point the turret 180 degrees or anything like that. I’m looking for a math wizard or something that could explain to me how it would be done. Thanks!

1 Like

You can use math.clamp(n, min, max) to limit a certain axis between min and max

Would I use something like CFrame.fromEulerAnglesXYZ to get the angles, I’ve never worked with that kind of CFrame stuff so i’m not sure what it does.

I don’t believe so, since that is a constructor for creating an instance of CFrame. I do not know how you turn the turret so I can’t help further until you elaborate on that

So currently I have the Turret Lerp to the mouse position

Turret.CFrame = Turret.CFrame:Lerp(CFrame.new(Turret.Position,Mouse.Hit.p),0.45)

I’m looking for an explanation for how I would do it