Trying to set max rotation for arm rotation script

hello! i made a script that basically rotates ur head and arms with the mouse but im trying to set like a min/ max threshold for rotation but not sure how to go about it. i appreciate any help ty!

script:


	connection = rs.RenderStepped:Connect(function()

local char = game.Players.LocalPlayer.Character
		local rightshoulder:Motor6D = char.RightUpperArm.RightShoulder
		local leftshoulder:Motor6D = char.LeftUpperArm.LeftShoulder
		local neck:Motor6D = char.Head.Neck
		local upperTorso:Motor6D = char.UpperTorso.Waist
			local lowerTorso:Motor6D = char.LowerTorso.Root
		
		local mouseHit = mouse.Hit	
			
			neck.CurrentAngle = 0
			upperTorso.CurrentAngle = 0
			lowerTorso.CurrentAngle = 0
		leftshoulder.CurrentAngle = 0
		rightshoulder.CurrentAngle = 0

		leftshoulder.C0 = CFrame.new(leftshoulder.C0.Position):Orthonormalize() * CFrame.Angles(0,math.deg(-mouseHit.X/800),0,0)
		leftshoulder.C1 = CFrame.new(leftshoulder.C1.Position):Orthonormalize() * CFrame.Angles(math.deg(mouseHit.Y/800),0,0)
		
		rightshoulder.C0 = CFrame.new(rightshoulder.C0.Position):Orthonormalize() * CFrame.Angles(0,math.deg(mouseHit.X/-800),0,0)
		rightshoulder.C1 = CFrame.new(rightshoulder.C1.Position):Orthonormalize() * CFrame.Angles(math.deg(mouseHit.Y/800),0,0)
		
		neck.C0 = CFrame.new(neck.C0.Position):Orthonormalize() * CFrame.Angles(0,math.deg(mouseHit.X/-800),0,0)
		neck.C1 = CFrame.new(neck.C1.Position):Orthonormalize() * CFrame.Angles(math.deg(-mouseHit.Y/800),0,0)
	end)

vid;

2 Likes