env_sun?

I’m trying to adapt a day/night addon to work with a map that doesn’t have an env_sun. I have done this so far



		if #ents.FindByClass("env_sun") >= 1 then
			SW.Sun = ents.FindByClass("env_sun")[1]
			SW.Sun:SetKeyValue( "targetname", "sun" )
			SW.Sun:SetKeyValue( "use_angles", "YES" )
			SW.Sun:SetKeyValue( "size", 16 )
			SW.Sun:SetKeyValue( 'material' , 'sprites/light_glow02_add_noz.vmt' )
			SW.Sun:SetKeyValue( 'overlaymaterial' , 'sprites/light_glow02_add_noz.vmt' )
		else
			SW.Sun = ents.Create("env_sun")
			SW.Sun:SetKeyValue( "targetname", "sun" )
			SW.Sun:SetKeyValue( "use_angles", "YES" )
			SW.Sun:SetKeyValue( "size", 16 )
			SW.Sun:SetKeyValue( 'material' , 'sprites/light_glow02_add_noz.vmt' )
			SW.Sun:SetKeyValue( 'overlaymaterial' , 'sprites/light_glow02_add_noz.vmt' )
		end


And the sun appears, but the material doesn’t seem to set, it appears as a strobing pink and black. Any solutions?

Spawn()
Activate()