If you have SQL Server 2012 and want to create Schema and data script for SQL Server 2008 R2 you can follow the following steps:
Right click the DB.
Select "Generate Scripts"
Go to Set Scription options and click "Advance options" and then select "SQL Server 2008 R2" value for "Script for Server Version" option.
That will generate the SQL Server 2008 R2 compatible schema and data script.