render.CopyTexture(from, to) ?

What is the function of “render.CopyTexture(from, to)”?

I’ve tried playing around with it, to copy a renderer to a texture, but failed:

local from = GetRenderTarget("GModToolgunScreen", 256, 256)
local to = Material("ash47/mytexture"):GetMaterialTexture("$basetexture")

render.CopyTexture(from, to)

Obviously I’m doing something wrong, feel free to tell me what I’m missing…

I’m simply running this code as is, using lua_openscript_cl, perhaps it needs to be in a hook somewhere?

If you want to replace a texture, set the $basetexture material property.

How? To be 100% clear, I want to copy the current renderer texture and replace any other texture I choose with it, I thought that’s what render.CopyTexture did…