How do I make my player detect the end of the wall and then rotate

You can write your topic however you want, but you need to answer these questions :

  1. What do you want to achieve?
    I want my character to detect that there isn’t a wall there anymore and rotate there character to align with the wall

  2. What is the issue?

  3. What solutions have you tried so far? I have already got the raycasting done that detects when there is no more of the wall for the player to go off of, but I’m having a hard time rotating them to align with that wall.

What I have so far.

while Controls.right == 1 do
			game:GetService("RunService").Stepped:Wait()
			local RightRay = Ray.new(humrp.Position, humrp.CFrame.lookVector * 5)
			local hit, position, surface = game.Workspace:FindPartOnRayWithIgnoreList(RightRay, {humrp,head})
			if not hit and Climbing and not _G.D then
				_G.D = true
				print("Nothing found here!")
			end
		end

You may need to add a part at the end and set CanCollide to false. And if the part was touched, do what you wanted.

If you are just trying to rotate to face another part, try setting the CFrame. I’d assume humrp.CFrame(if this is the HumanoidRootPart) = CFrame.new(humrp.Position, wall.Position) it’s late and that might be wrong but I think it’s correct(?).

It’s kinda funny I forgot it already after doing a ton of CFrame on my project, whoops.

Edit: Looking back at the video, I don’t know if this would be the solution or the best solution, but you could always try.

You can disable auto rotate and then change the character’s relative rotation by 90 degrees if there is no more of the wall for the player to go off of and climbing towards the right, and change the character’s relative rotation by -90 degrees if climbing towards the left, and see what that does.

local rotatedCFrame = nil
if Controls.right then
    rotatedCFrame = CFrame.Angles(0, math.rad(90), 0)
else
    rotatedCFrame = CFrame.Angles(0, math.rad(-90), 0)
end

if rotatedCFrame then
    humrp.CFrame = humrp.CFrame:ToWorldSpace(rotatedCFrame)
end

I’ll make sure to try that thank you!