Problem with displaying metadata of an entity

Greetings all,

I have been having problems with displaying metadata of an entity. I
am trying to modify the my_forms.php under the form plugin to display
some information to the user. My code segment is as following:

(pre-existing objects: $entity)

               $entity_guid = $entity->getGUID();
               $name = 'your_weight';
               $id = get_metastring_id($name);
               echo elgg_echo($id);    //statement 1
               $weight = get_metadata_byname($entity_

guid, $name);
               echo elgg_echo($weight_num);    //statement 2

$entity is an entity initialized earlier in the code, which has a
metadata named "your_weight". I want to retrieve the value of this
metadata and display it to the user. However, statement 1 works fine
but statement 2 doesn't work. Nothing is displayed from statement 2.

Can anyone give me some suggestions?

Thank you so much!