I see, could the problem be because you are setting the CFrame of the LowerTorso instead of the HumanoidRootPart? Other than that, I haven’t touched CFrame in a while so this is beyond my expertise at the moment.
I’m not sure. I tried replacing the tween with the HRP and tweening the CFrame while keeping the math part the same, but my character kept going back to the origin. I’ll have to look more into that
One last possibility is that you should be setting only the y value of the torso’s C0 back to original y value. The x and z value of the torso should be retained.
char.LowerTorso.Root.C0 = Vector3.new(char.LowerTorso.Root.C0.X, originalC0.Y, char.LowerTorso.Root.C0.Z)
I’m not sure where I would put that code in though…The way I did the tilting was using CFrame.Angles, and then only changing the Z part. I didn’t touch the X or Y value at all.
C0 = CFrame.Angles(0,0,(-math.asin(CameraDirection.X)/1.8) * 4)
The reason you get stuck in the orientation is because Character.LowerTorso.Root.C0
is a static property, meaning when you set it, it does not change until you set it again.
You can get around this by adding a script to the LowerTorso that has a Motor6D and setting that motor to the same values as your CFrame
.
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local HRP = char.HumanoidRootPart
local bv = Instance.new(‘BodyVelocity’)
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Name = ‘FlightForce’
bv.Velocity = Vector3.new(0,0,0)
bv.Parent = HRP
local bg = Instance.new(“BodyGyro”)
bg.MaxTorque = Vector3.new(100000,100000,100000)
bg.Name = ‘Flying Stabilizer’
bg.D = 7500
bg.P = 750000
bg.CFrame = HRP.CFrame --[Not really sure what to put here]
bg.Parent = HRP
—[The main movement stuff]—
game:GetService(“RunService”).RenderStepped:Connect(function()
local CameraDirection = HRP.CFrame:ToObjectSpace(camera.CFrame).lookVector
local characterPosition = HRP.CFrame.Position
local charNextPosition = characterPosition + HRP.Velocity.Unit
if wPressed then --[If player presses W, then wPressed = true and the player flies. Don't worry about this part]--
HRP:FindFirstChild('FlightForce').Velocity = camera.CFrame.LookVector * speed --[Flying based on Camera Direction]--
HRP.CFrame = CFrame.lookAt(characterPosition,charNextPosition)--[makes the character look based on the direction of the velocity. So if they are looking to the right, their character will turn to the right, but it won't