Side-To-Side Movement On Wall

I have a script that allows a player to climb up walls. The problem with this though is that it only works for one side of a part when im using it.

local function EnableClimb()
	if not ClimbingWall and Humanoid:GetState() == Enum.HumanoidStateType.Freefall then  
		local Raycast = workspace:Raycast(HumRootPart.Position, HumRootPart.CFrame.LookVector * 1.5, RaycastParams.new())


		ClimbingWall = true


		if Raycast and Raycast.Instance.Size.Y > 5 then
			local FocusPart = Raycast.Instance



			local ClimbValue = 2
			local ClimbSideValue = 0
			local ClimbPower = 1
			
			TweenService:Create(Humanoid, TweenInfo.new(0.4, Enum.EasingStyle.Exponential), { CameraOffset = Vector3.new(0,0,0.3) }):Play()
			TweenService:Create(camera, TweenInfo.new(0.4, Enum.EasingStyle.Exponential), { FieldOfView = 160 }):Play()
			
			

			local ClimbConnect = RunService.RenderStepped:Connect(function()
				if ClimbingWall == false then return end
				
				Humanoid.WalkSpeed = 0
				
				
				
				local CheckRaycast = workspace:Raycast(HumRootPart.Position, HumRootPart.CFrame.LookVector * 1.5, RaycastParams.new())

				if CheckRaycast and CheckRaycast.Instance == FocusPart then

				else

					DownFOVTween:Play()
					ClimbingWall = false
					return

				end
				
				if CurrentInputW == true and MoveClimbTrack.IsPlaying == false then
					IdleClimbTrack:Stop()
					MoveClimbTrack:Play()
				elseif CurrentInputW == false then
					MoveClimbTrack:Stop()
						IdleClimbTrack:Play()
				end

				HumRootPart.AssemblyLinearVelocity = Vector3.new(ClimbSideValue, ClimbValue * ClimbPower, 0)

			end)




			while task.wait(0.1) do
				if CurrentInputW == true then
					ClimbPower = 10
				else
					ClimbPower = 1
				end
				
				if CurrentInputA == true then
					ClimbSideValue = 15
				elseif CurrentInputD == true then
					ClimbSideValue = -15
				else
					ClimbSideValue = 0
				end
				

			end

		end
	end
end

The problem is in the while true loop, how would i be able to get it, when the player is on the part, for the player to move side-to-side relative to the face of the part there on.

bumping the topic to get a quicker reply

I assume this needs to be rotated using part.CFrame:VectorToWorldSpace(…).
(Not Point since it’s velocity)

^ kind of
I believe you might actually want the CFrame.lookAlong(Vector3.zero, surfaceNormal, Vector3.yAxis) instead of part.CFrame

1 Like

Thanks for the answer, ill look into it!

That works great! but one more request, can you bread down the line of code you gave me for future reference?

So the surfaceNormal is the look vector, the y axis is the up vector and the position is zero.
So CFrame.lookAlong takes position, lookvector, upvector.
And then VectorToWorldSpace rotates the vector with respect to the cframe. So vector you would rotate is Vector3.new(leftRightValue, upDownValue, inOutValue).
Since the CFrame we are using has zero position, PointToWorldSpace and VectorToWorldSpace act the same.

forgot to give you the solution sorry!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.