Hey, I’m trying to change the characters orientation to face a similar orientation to where the player’s camera is facing.
Currently I have BodyGyro and BodyVelocity set up so that the characters would start flying in the direction of where the camera is pointing, although the player’s orientation is not rotated with it.
repeat wait()
local cam = game.ReplicatedStorage.getCam:InvokeClient(player)
local goTo = cam
bgyro.CFrame = goTo * CFrame.new(0,0,-50) --BodyGyro
bvel.Velocity = goTo.LookVector * 150 --BodyVelo
local hrp = character:WaitForChild("HumanoidRootPart")
hrp.CFrame:ToOrientation(goTo.LookVector.X,goTo.LookVector.Y, goTo.LookVector.Z)
until WereFinished = true
I’m assuming cam is the CFrame of the Camera and not the Camera instance itself since the server cannot see the player camera instance
Firstly, you are calculating a CFrame but you’re not assigning it to anything
You’d have to do:
hrp.CFrame = hrp.CFrame:ToOrientation(…
Secondly, CFrame:ToOrientation() extracts the Orientation data from an existing CFrame, it doesn’t create a CFrame
The function you’re looking for is CFrame.fromOrientation()
hrp.CFrame = CFrame.fromOrientation(…
Lastly, LookVector is a vector pointing in the direction a CFrame is facing while the Orientation is the X,Y,Z rotation components, you cannot use the LookVector to create an orientation CFrame
With these in mind, the code should be something like:
One last thing, both BodyGyro and BodyVelocity have been deprecated in favor of AlignOrientation and LinearVelocity so I’d suggest you use those instead as they should be more stable