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