I have a fly script that I would like to make so that when you stop moving the align orientation tilts the character upright I have an idea of where its supposed to go into the script but idk how to set the align orientation so that it tilts the character upright heres my script and a video.
https://i.gyazo.com/a84a3ba2b41ab16a706c81b0067b61d4.mp4
local function FlyAction(ActionName, InputState, InputObject)
if InputState ~= Enum.UserInputState.Begin then return Enum.ContextActionResult.Pass end
if Connection == true then return Enum.ContextActionResult.Pass end
if Connection == nil then
Connection = true
if Character.Humanoid.FloorMaterial ~= Enum.Material.Air then
Character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
task.wait(0.1)
end
VectorForce.Enabled = true
AlignOrientation.CFrame = PrimaryPart.CFrame
AlignOrientation.Enabled = true
Character.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
Connection = RunService.Heartbeat:Connect(function(deltaTime)
VectorForce.Force = GravityVector * PrimaryPart.AssemblyMass
local MoveVector = Vector3.new(Character.Humanoid.MoveDirection.X, Yaxis, Character.Humanoid.MoveDirection.Z)
if MoveVector.Magnitude > 0 then
MoveVector = MoveVector.Unit
VectorForce.Force += MoveVector * Force * PrimaryPart.AssemblyMass
if math.abs(MoveVector.Y) == 1 then
AlignOrientation.CFrame = CFrame.lookAt(Vector3.new(0,0,0), MoveVector,-PrimaryPart.CFrame.LookVector) * CFrame.fromOrientation(-math.pi/2,0,0)
else
AlignOrientation.CFrame = CFrame.lookAt(Vector3.new(0,0,0), MoveVector) * CFrame.fromOrientation(-math.pi/2,0,0)
end
else
--Turn Upright Goes Here Prob Something like this maybe?
--AlignOrientation.CFrame = PrimaryPart.CFrame * CFrame.Angles(0, math.rad(90), 0)
end
if PrimaryPart.AssemblyLinearVelocity.Magnitude > 0 then
local DragVector = -PrimaryPart.AssemblyLinearVelocity.Unit * PrimaryPart.AssemblyLinearVelocity.Magnitude ^ 1.5
VectorForce.Force += DragVector * Drag * PrimaryPart.AssemblyMass
end
VectorForce.Force -= Vector3.new(0,50,0)
end)
else
VectorForce.Enabled = false
AlignOrientation.Enabled = false
Character.Humanoid:ChangeState(Enum.HumanoidStateType.Freefall)
Connection:Disconnect()
Connection = nil
end
return Enum.ContextActionResult.Pass
end
local function UpAction(ActionName,InputState,InputObject)
if InputState == Enum.UserInputState.Begin then Yaxis = 1 else Yaxis = 0 end
return Enum.ContextActionResult.Pass
end
ContextActionService:BindAction("Fly", FlyAction, true, Enum.KeyCode.R)
ContextActionService:BindAction("Up",UpAction,true,Enum.KeyCode.Space)