BodyGyro shifts into the wrong orientation

So basically, I was making a Wall Climbing system in the steps of this post: Making a "Wall Climbing" System - #6 by Stealthied

It all went well so far until I was free falling before I pressed C to climb, which resulted in the body gyro shifting into the wrong orientation.

One of the solutions I have tried consist of this:

Here is the code provided:

function OnClimb()
	local Origin, Direction = RootPart.Position, RootPart.CFrame.LookVector
	local RaycastResult = workspace:Raycast(Origin, Direction)

	if RaycastResult then
		Climbing = true


		BodyVelocity.Velocity =, RaycastResult.Position + RaycastResult.Normal)
		BodyGyro.CFrame = CFrame.lookAt(RootPart.Position, RaycastResult.Position)
		BodyVelocity.Parent = RootPart
		BodyGyro.Parent = RootPart

		Humanoid.PlatformStand = true
		Humanoid.AutoRotate = false


			if RootPart.Position.Y > RaycastResult.Instance.Size.Y + 3 then
		until (not Climbing)

this has been a problem for me too. A hacky solution I found was setting the CollisionGroup of the player (or the part) to something different than eachother.

I have attempted this but it appears that the BodyGyro’s problem remains.

	local Parameters =
	Parameters.FilterDescendantsInstances = Blacklisted
	Parameters.FilterType = Enum.RaycastFilterType.Blacklist
	Parameters.CollisionGroup = "Climb"
	Parameters.IgnoreWater = true

Not exactly sure, have you tried Using the raycasts Normal instead of LookAt?

I have tried using RaycastResult.Normal along with rather than CFrame.lookAt()