change skybox via script help ?

Hey i’m trying to change the skybox material via javascript .
i make this(down below) script and for some reason it’s not working !!
can anyone help me plz ! this is the script that i’v made
------------------------------------------------------------------------->

#pragma strict

var dayMaterial:Material; 
var nightMaterial:Material;
var Timer : float = 20.0;
RenderSettings.skybox = dayMaterial;

function update()
{
Timer = Time.deltaTime;
if(Timer <=20.0)
 {
RenderSettings.skybox = dayMaterial;
 }

if(Timer <=10.0)
 {
 RenderSettings.skybox = nightMaterial;
 }
}

This will do roughly what you want, its is cut down version of your script and will change from your current skybox to the one selected in this script(in the inspector box for the material var) after 10 seconds. I have fixed all your errors and you should be able to build upon this for your specific needs. I’ve left the Timer var as public so you can see what is happening to it in the inspector window when running.

#pragma strict

public var mNight_Sky : Material; 
public var Timer : float = 10f;

function Update() {

    if (Timer > 0) {
        Timer = Timer - Time.deltaTime;
    }
    
    if (Timer <= 0f) {
        RenderSettings.skybox = mNight_Sky;
    }
}

Wow it’s really working thnx bro (MrSoad) !
if anyone want the new script for changing the sky box here it is !
Dose anyone know how to fade it like when it change not like booom it’s changed > i want to fade it like bring down the skybox opacity with time !

#pragma strict

 public var Night_Sky: Material;
 public var Day_Sky: Material;  
 public var Timer : float = 20f;
 
 function Update() {
 
     if (Timer > 0) {
         Timer = Timer - Time.deltaTime;
     }
     
     if (Timer <= 10f) {
         RenderSettings.skybox = Day_Sky;
     } 

     
     if (Timer <= 0f) {
         RenderSettings.skybox = Night_Sky;
     }
 }