Material Scripting Metallic Texture


I have created two different metallic textures for my AlbedoTexture. The one is called (for dry weather) and the second is called (for wet weather)
I 'm trying to crate a script so that the sim would read the first one when it does not rain and the other one when it rains whilst the AlbedoTexture remains the same.
Here is the script I use. Of course, it does not work and I'm trying to find out how and if I can make it work.

--Get precip state.
local raining = 0x00000004
local precipState = varget("A:AMBIENT PRECIP STATE", "Mask")
precipState = math.floor(precipState)
local StringOld = varget("T:MetallicTexture", "String")
local StringNew

if precipState == raining then
StringNew=string.sub(StringOld,1,8) .. "_RA.DDS"
StringNew=string.sub(StringOld,1,8) .. ".DDS"


I do not even know if a script could work to change the metallic texture for the same Albedo one.

Can anybody help?