Climb Script Doesn't Do Anything

I have this script here in 'StarterPlayerScripts" that allows the player to climb any wall with a slope higher than 89. I’ve been debugging and found out it doesn’t detect the collided part as a BasePart(line 3). I’ve also tried replacing line 3 with "IsA(“Part)” and it still doesn’t detect. Any ideas?

local minSlopeAngle = 89

local function onCollision(hit)
    if hit and hit:IsA("BasePart") and hit.CanCollide then
        local surfaceNormal = hit.CFrame:VectorToWorldSpace(Vector3.new(0, 1, 0))
        if surfaceNormal.Magnitude > 0.01 then -- make sure the normal is normalized
            local slopeAngle = math.deg(math.acos(surfaceNormal:Dot(Vector3.new(0, 1, 0))))
            if slopeAngle >= minSlopeAngle then
                local humanoid = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
                if humanoid then
                    humanoid.WalkSpeed = 0
                    humanoid.JumpPower = 0
                    humanoid.AutoRotate = false
                    humanoid.AutoRotateSpeed = 0

                    local startTime = tick()
                    while tick() - startTime < 1 do
                        local climbDirection = Vector3.new(0, 1, 0)
                        humanoid:MoveTo(humanoid.RootPart.Position + climbDirection)
                        wait()
                    end
                end
            end
        end
    end
end

game.Players.LocalPlayer.Character.HumanoidRootPart.Touched:Connect(onCollision)
1 Like

Hello, well for starters i have to say that humanoid:MoveTo() won’t move you upwards if you add something to the Y vector, for climbing you have to use a body mover

like jump? because thats what I kinda wanted yeah

Not like jump, rather you must create a bodyvelocity or something that stops humanoid from acting i’d even suggest making it PlatformStand, Climbing is an entire new type of movement so you have to handle it 100% manually with either body movers (physics) or CFrame

well with doublejump scripts they use jump when in midair so I was assuming the same could be done for this. I could be wrong though

As @DevSersponge said, an AlignPosition should work for you. It replaced the deprecated BodyPosition mover.

Correct me if I’m wrong, but I don’t think this is a valid property of the Humanoid.