Picture Sliding script not working

Problem is that when i hit the unity play button it works fine but when i make a demo world or publish it then it is not changing images

 [Header("Set the speed(It is seconds)."), Range(1, 40)]
        public float speed = 5.0f;
        [Header("Add Images here.")]
        public List<Texture2D> textures;
        [Header("Do not touch beound this.")]
        public Material material;
        private float timer;
        public TextMeshPro text;

        void Start() {
            material.mainTexture = textures[1];
        }

        void Update() {
            timer += Time.deltaTime;

                text.gameObject.SetActive(!text.gameObject.activeSelf);
            text.text = timer.ToString();
           
            if (timer > speed) {
                timer = timer - speed;
                ChangeImage();
            }
        }

        private void ChangeImage() {
            int index = textures.FindIndex(t => t == material.mainTexture);

            if (index == textures.Count - 1) material.mainTexture = textures[0];
            else material.mainTexture = textures[index + 1];
        }