This code is supposed to play a sound when I press 'E' but it's not working. also keep in mind I'm new to unity and coding in general so don't be to harsh if I made a really dumb mistake.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class flashlightonoffsound : MonoBehaviour
{
public AudioSource flashlightsound;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.E))
{
flashlightsound.Play();
}
else
{
flashlightsound.Stop();
}
}
}