I am making a 2D game, and I have a script that makes the player face whichever direction the mouse is pointing, and it works properly.
while character:FindFirstChild("Humanoid").Health > 0 do
game:GetService("RunService").Stepped:Wait()
character.UpperTorso.CFrame = CFrame.new(character.UpperTorso.Position, Vector3.new(mouse.Hit.p.X, character.UpperTorso.Position.Y, mouse.Hit.p.Z))
end
However, I have transparent parts that act as hitboxes, and it because of this, it causes inconsistencies…
(In the image, the player is not facing the mouse because there is a hitbox above the tree).
But there is one thing; to change the CanQuery property, the part needs to have the CanCollide property set to false (not sure if changing it through a script will work, but you can try it by categorizing transparent parts and using a for index loop). If that doesn’t work, I suggest trying @Dfzoz’ solution, as I don’t think you can set ignorelists for the mouse, like you can with Raycasting.
I forgot to mention that these hitboxes had cancollide to false - they were meant so that players couldn’t place objects to close to another object, I may have used the wrong terminology, apologies.