Odd behaviour with CFrame:Inverse()

So I have a flying head of the player’s character, I destroy the neck motor6d and I am making the head look at the camera when the right mouse button is held.

Mouse.Button2Down:Connect(function()
	if Player.Team == game.Teams.Spectators then
		RightMouseHeld = true
		while RightMouseHeld == true do
                Head.CFrame = CFrame.lookAt(Head.CFrame.Position, Camera.CFrame.Position)
                task.wait()
		end
	end
end)

Mouse.Button2Up:Connect(function()
	if Player.Team == game.Teams.Spectators then
		RightMouseHeld = false
	end
end)

This works however the head is looking backwards, so I decided to inverse the CFrame:

Head.CFrame = CFrame.lookAt(-Head.CFrame.Position, -Camera.CFrame.Position)

This does work, as the head starts looking in the correct direction. But an unintended side effect is that the head literally can’t move and starts bugging out, it randomly starts teleporting everywhere.

I’ve tried messing around with network ownership nothing changed really,

I also tried using bodygyros, but that’s a whole other topic of mine that has still not been solved:

Welp, I guess this topic is also gonna go unsolved.

Instead of just subtracting the vectors, just change the angle

Head.CFrame = CFrame.lookAt(Head.CFrame.Position, Camera.CFrame.Position) * CFrame.Angles(0, math.rad(180), 0)
2 Likes

THANKS OMG YOU ARE A GENIUS. A GODAMN GENIUS, I’VE BEEN STURGGLING FOR 3 DAYS.

AND BY THE WAY I WAS LITERALLY SITTING ON MY PC AND FIGURED OUT THE PROBLEM THE SAME TIME YOU WROTE THIS POST,

I WAS THINKING IN MY HEAD "HMM, WELL CFRAMES REPRESENT BOTH POSITION AND ORIENTATION SO IF I INVERSE THE ORIENTATION IM ALSO INVERSING THE POSITION. WELL WHATS THE SOLUTION TO THIS?

THEN AT THE SAME GODAMN TIME YOU CAME AND WROTE THIS MASTERPIECE. THANK YOU DATASIGH, AND YOUR MODELS ARE BEAUTIFUL JUST LIKE YOUR TALENTED PROGRAMMING SKILLS!

whyroblox

1 Like

np

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.