Primary fire scopes in?

I’m making a swep where when you click mouse one it goes into iron sight, then a little delay, you fire it comes out of iron sight/scope. What would be the code for that? Any help is greatly appreciated.
Thanks