Question by 
               Dajuice  · Dec 18, 2015 at 12:35 AM · 
                c#beginnerlightsound on key  
              
 
              Cant get sound play on input
 I dunno what Im doing wrong I wrote this toggle script to turn a light on and off but it wont play my sound along with the light. The sound plays on awake but not when i press the input. Im just trying to get work like the switch on a flashlight. 
 
               heres the code:
 using UnityEngine;
 using System.Collections;
 
 public class headlight : MonoBehaviour {
 
     //light toggle on and off
     public Light light1;
     public AudioClip onswitch;
 
     private AudioSource source;
     //
     void awake ()
     {
         source = GetComponent<AudioSource>();
     }
     
 
     /// </summary>
 
     void Update () 
     {
         if (Input.GetKeyDown ("l")) 
             {
             
             light1.enabled = !light1.enabled;
             source.PlayOneShot(onswitch, 1F);
         }
     }
 
 
 
 
 
 
 
     }
 
              
               Comment
              
 
               
              Answer by OncaLupe · Dec 18, 2015 at 02:38 AM
Methods are case sensitive. This line:
 void awake ()
 
               should be:
 void Awake ()
 
              Omg Thank YOU!!! IT TOTALLY WOR$$anonymous$$ED. I need to study code waaay more.
Your answer
 
             Follow this Question
Related Questions
How do i convert game object counts, into int, and put into string? 0 Answers
Use a class like a function 1 Answer
How can i place subjects in different positions? 0 Answers
Accessing Variables inside classes inside other classes? 1 Answer
What Does It Mean By GetComponent & How do you Use It?! 1 Answer