Is there any way to take an ingame screenshot through script and use it as an image?

I would use it to automatically set Tools’ TextureId