Wall climbing issue

  1. What do you want to achieve?

I want to make a wall climbing system where you can rotate around the surface of any climbable part and smoothly attach onto it and off.

  1. What is the issue?

The issue is that I don’t know how make a player’s character position and orientate itself relative to the surface of part. When I test the code below on some sides of a part the player’s character will not completely orientate themselves with the surface of the part and even look opposite to the wall.

Wall Climbing Client
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CS = game:GetService("CollectionService")

--Player variables
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local humanoidRootPart = character.PrimaryPart

local raycastTarget = nil

local function EditMovement(AutoRotate,WalkSpeed,JumpPower)
	humanoid.AutoRotate = false
	humanoid.WalkSpeed = 0
	humanoid.JumpPower = 0
end

local function AlignOrientation()
	local alignOri = Instance.new("AlignOrientation")
	alignOri.Attachment0 = humanoidRootPart:WaitForChild("RootAttachment")
	alignOri.Responsiveness = 100
	alignOri.MaxTorque = 1e6
	alignOri.Mode = Enum.OrientationAlignmentMode.OneAttachment
	alignOri.Parent = humanoidRootPart
end
local function AlignPosition()
	local alignPos = Instance.new("AlignPosition")
	alignPos.Attachment0 = humanoidRootPart:WaitForChild("RootAttachment")
	alignPos.Responsiveness = 100
	alignPos.MaxForce = 1e6
	alignPos.Position = humanoidRootPart.Position
	alignPos.Parent = humanoidRootPart
end

local function Raycast()
	local params = RaycastParams.new()
	params.FilterType = Enum.RaycastFilterType.Exclude
	params.FilterDescendantsInstances = {character}
	
	local origin = humanoidRootPart.Position
	local direction = humanoidRootPart.CFrame.LookVector * 5
	
	local raycast = workspace:Raycast(origin,direction,params)
	if raycast then
		raycastTarget = CFrame.new(raycast.Position,raycast.Position + raycast.Normal)
	end
end

local function Initiate()
	AlignOrientation()
	AlignPosition()
	Raycast()
	EditMovement(false,0,0)
end

for _,Wall in pairs(CS:GetTagged("Wall")) do
	Wall.Touched:Connect(function()
		Initiate()
		if raycastTarget ~= nil then
			humanoidRootPart.CFrame = raycastTarget
		end
	end)
end
Example

Example1

  1. What solutions have you tried so far?

I’ve attempted to make wall climbing systems in the past and i’ve paused them because I couldn’t do them. I’m attempting to make a wall climbing system again after learning more.

Can someone bump this post please?