How would you make your character face your camera/mouse/a certain object (for flying script)?

How would I make it so that when you’re flying, your character faces your camera/mouse so if you’re looking/pointing down, your character will face downwards for example?

(example below in super power training simulator)

I’m only looking for the code that makes your character face a certain way. Even if the code is not with a flight script, I’ll be able to merge it.

I can’t really think of a way to achieve this effect. One possible option is to constantly set your character’s HumanoidRootPart CFrame (or possibly another part) to where your camera/mouse is facing, but it’s janky.

I could try some sort of orientation bodymovers/constraints. (psst: i like the legacy bodymovers because i don’t have to make and add an attachment)

The craziest method I thought of would be to clone the player’s character which will then align with the camera/pointer. Since that’s not actually your character, it won’t mess around with any position/movement things which was a problem in the first possible option. This won’t really be good for standard avatars because the clothes might not be visible on the dummy.

BodyGyro.CFrame = CFrame.new(game.Workspace.CurrentCamera.CFrame.Position, game.Players.LocalPlayer.Position) (In a localscript)

I think the code above will work.

It sadly didn’t work and I got this weird error message.
image

local bg = Instance.new("BodyGyro")
bg.Parent = game.Players.LocalPlayer.Character.UpperTorso
bg.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
bg.D = math.huge
bg.P = math.huge

game:GetService("RunService").RenderStepped:Connect(function()
	bg.CFrame = CFrame.new(game.Workspace.CurrentCamera.CFrame.Position, game.Players.LocalPlayer.Character.HumanoidRootPart.Position)
end)

It seems that the math.huges are causing the script to cause an error

Should work now

local bg = Instance.new("BodyGyro")
bg.Parent = game.Players.LocalPlayer.Character.UpperTorso
bg.MaxTorque = bg.MaxTorque = Vector3.new(375000,375000,375000)
bg.D = 10

game:GetService("RunService").RenderStepped:Connect(function()
	bg.CFrame = CFrame.new(game.Workspace.CurrentCamera.CFrame.Position, game.Players.LocalPlayer.Character.HumanoidRootPart.Position)
end)

It kinda works (after tweaking stuff like dampening and power), however looking too high up or down causes the character to be very shaky. I would use this as a back up if I can’t think of anything else.

Thank you.