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.