How to script a table?
From 2012 onwards this is possible and can be done with help OF sys.dm_exec_describe_first_result_set DMV.


  This dynamic management function takes a Transact-SQL statement as a
  parameter and describes the metadata of the first result set for the
  statement


You can refer here for a read on this sys.dm_exec_describe_first_result_set

Also, refer to this post explaining the same. Is there a way to generate table create script in TSQL?