In need of help with Clicker Game

Need help with this script no errors but not doing its task. First of all I am trying to make it so when the player is constantly clicking the cookie it will burst smaller chunks around and only when he stops clicking it it will stop too. Yet I had no luck of prolonging the particle effect.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Particle : MonoBehaviour
{
    public ParticleSystem CookieParticles;
    public float InternalTimer = 3;
    public void ClickTheButton()
    {
        InternalTimer += 0.5f;
        if (CookieParticles.isPlaying)
        {

        }
        else
        {
            CookieParticles.Play();
            StartCoroutine(Timer(InternalTimer));
        }
    }

    IEnumerator Timer(float InternalTimer)
    {
        yield return new WaitForSeconds(InternalTimer);
        CookieParticles.Stop();
    }
}

Your code (in terms of working) looks correct. Maybe try having burst particles and instantiating them whenever the button was clicked. Right now, if you click the button the Particle System get’s stoped after 3.5 seconds no matter how often you click. If you click after those 3.5 seconds, it will start again. The time until it stops again depends on the amount of clicks in those 3.5 seconds.

Also, have you heared of the “!” operator? :wink: