Kinematic how to know rigidbody velocity vector?

Hello there, I have moving object and its son is a kinematic rigidbody, is there a way to know the velocity vector ? I tried to access with rigidbody.velocity but it says “there is no rigidbody attached” bug??

Thanks alot!!

function Start(){

   oldpos = transform.position;
}

function Update(){
    newpos = transform.position;
    var media =  (newpos - oldpos);
    velocity = media /Time.deltaTime;
    oldpos = newpos;
    newpos = transform.position;
}