How to make a ladder script

Hi, I am trying to do a ladder script for my game, but my script dosen’t work.

Is there anything wrong with this script? My player falls through the ground and stuff with this script.

Script:

public var smooth : float;
public var Ladder : boolean = false;


public var newPosition : Vector3;



function Awake ()
{
    newPosition = transform.position;
    
}


function Update ()
{
    PositionChanging();
    
}


function PositionChanging ()
{
    var positionA : Vector3 = new Vector3(576.3549, 17.97417, 174.8432);
    var positionB : Vector3 = new Vector3(583.3901, 57.30544, 174.8432);
    
    if(Input.GetKeyDown(KeyCode.W))
        newPosition = positionA;
        
    if(Input.GetKeyDown(KeyCode.S))
        newPosition = positionB;
    
    transform.position = Vector3.Lerp(transform.position, newPosition, smooth * Time.deltaTime);
}

If you can stand over the ladder without the script, so you needs to raise a little the y positionA/B coordinates.

If you can’t, so you needs a collider for your ladder.

How to make a ladder: How do I create a climbable ladder? - Questions & Answers - Unity Discussions