Brake Light Button

Hey fellas i got a question in unity about brake lights i am very new to unity i developed a car game but i can’t seem to get the brake lights to work i created a script but when i place script it works but when i hold (s) it keeps turning the light on and off

and i want if i press (s) it keeps the light on but when i remove my finger it stops lighting.

Here’s the script i made:

function Update() {

if (Input.GetButton(“s”)) {

if (light.enabled == false)

    light.enabled = true;
    
    else
    	
    	light.enabled = false;
}

}

can you send me the finished script thanks in advance

Hi,

No I cannot give you the finished script.

Input.GetButtonDown and Input.GetButtonUp should work in your case : lights on when s down, off when up.