With limited details it's difficult to help you but you could parse the UserId (and any other variables) to another script by using something like the following in your sub (or plugin) -
print "Location:http://www.yourdomain.com/cgi_directory/script_name.cgi?UserId=$tags->{UserId}&other_name=$tags->{variable_name}\n\n";
Your other script would need to process the input.
print "Location:http://www.yourdomain.com/cgi_directory/script_name.cgi?UserId=$tags->{UserId}&other_name=$tags->{variable_name}\n\n";
Your other script would need to process the input.