I can enter playmode with this script , could someone help me ?

Hi everyone, im looking for some help given that im not very avid on the coding side , i´m making a candle and got the model and the flame working i just wanted to ad a flickering light for that little bit extra of detail , and found this code , that goes between a min and max value (so it doesn´t turn off completley) but i cant make it work , when i try to play it says it uses outdated api and that unity will convert it , y hit okey and then when y press play its like the screen just blinks and never goes into playmode, without any warning.

using UnityEngine;
using System.Collections.Generic;

// Written by Steve Streeting 2017
// License: CC0 Public Domain http://creativecommons.org/publicdomain/zero/1.0/

/// <summary>
/// Component which will flicker a linked light while active by changing its
/// intensity between the min and max values given. The flickering can be
/// sharp or smoothed depending on the value of the smoothing parameter.
///
/// Just activate / deactivate this component as usual to pause / resume flicker
/// </summary>
public class LightFlickerEffect : MonoBehaviour {
    [Tooltip("External light to flicker; you can leave this null if you attach script to a light")]
    public new Light light;
    [Tooltip("Minimum random light intensity")]
    public float minIntensity = 0f;
    [Tooltip("Maximum random light intensity")]
    public float maxIntensity = 1f;
    [Tooltip("How much to smooth out the randomness; lower values = sparks, higher = lantern")]
    [Range(1, 50)]
    public int smoothing = 5;

    // Continuous average calculation via FIFO queue
    // Saves us iterating every time we update, we just change by the delta
    Queue<float> smoothQueue;
    float lastSum = 0;


    /// <summary>
    /// Reset the randomness and start again. You usually don't need to call
    /// this, deactivating/reactivating is usually fine but if you want a strict
    /// restart you can do.
    /// </summary>
    public void Reset() {
        smoothQueue.Clear();
        lastSum = 0;
    }

    void Start() {
         smoothQueue = new Queue<float>(smoothing);
         // External or internal light?
         if (light == null) {
            light = GetComponent<Light>();
         }
    }

    void Update() {
        if (light == null)
            return;

        // pop off an item if too big
        while (smoothQueue.Count >= smoothing) {
            lastSum -= smoothQueue.Dequeue();
        }

        // Generate random new item, calculate new average
        float newVal = Random.Range(minIntensity, maxIntensity);
        smoothQueue.Enqueue(newVal);
        lastSum += newVal;

        // Calculate new smoothed average
        light.intensity = lastSum / (float)smoothQueue.Count;
    }

}

thanks for reading.

The script works for me.

I created a new project in two different versions of Unity (2019.4.15f1 and 2020.1.13f1).
In the Hierarchy, I created a Capsule and added a Directional Light as a child of the Capsule.
I added your script to the Directional Light and the flicker effect worked.

You could try to do the same and see if it works for you. If it does, then there must be something in your Project that’s preventing it from working.

Small note aside,

that’s a very basic script you can refactor or even create your own one,
just think about “what makes a light flicker” or “how can i do it”,

by increasing its “light intensity” +50~60 or by turning it off/on and modify its light intensity by +/- 10(depending),

based on that information its easy to make it,

ALSO,
i think with nowdays the existing “particle system” its possible todo that without coding (not sure)

thanks for the info, i´ll definitely look into that for future reference !

thank , i´ll check that its weird that for me isnt compiling