Rotating player torso to mouse regardless of rotation

I am trying to make the players torso point towards the mouse, the problem that i am facing is that when the character is flipped the rotation of the player torso is invented

–video

–script for rotating the players torso

	local function loop()
	
		
		--rotate player torso twords mouse position 
		local look, orgPos = mouse.Hit, self.realPlayerModel:WaitForChild("HumanoidRootPart").CFrame
		look = look:ToWorldSpace(CFrame.new(0, 0, 1.5))
		
		local x,y,z = look:ToEulerAnglesXYZ()
		local rx,ry,rz = orgPos:ToEulerAnglesXYZ()
		

		local newLook = CFrame.Angles(0,0,z) * CFrame.Angles(0, math.pi/-2, 0)
		local newOrig = CFrame.Angles(rx,ry,rz)
		newLook = newOrig:ToObjectSpace(newLook)
		
		remoteEvents.setTilt:FireServer(newLook)
		self.realPlayerModel.UpperTorso.Waist.C0 =  self.realPlayerModel.UpperTorso.Waist.C0:Lerp(CFrame.new(self.realPlayerModel.UpperTorso.Waist.C0.p) * newLook, 0.1)
	end


2 Likes

Just a quick bump to make sure people see this

Try doing it with BodyGyro

local Player = game.Players.LocalPlayer

local Mouse = Player:GetMouse()


local BodyGyro = Instance.new("BodyGyro")
BodyGyro.MaxTorque= Vector3.new(math.huge, math.huge, math.huge)
BodyGyro.CFrame = CFrame.new(Mouse.Hit.p) * Player.Character.HumanoidRootPart.CFrame

-- // Will work I guess / Make local script, it should be server sided anyways.