- Home /
Duplicate Question
Audio Script doesn't work
Hi everyone! so i have this script which i want to play a sound trough all scenes expect for 1 particular scene that is called BehindLocks. After i apply my script to an empty gameObject and add sound to the gameObject and after i start my game the script doesn't seem to work for some reason. the music plays trough out all of the scenes and doesn't stop when i am at the BehindLocks scene. Before i startup my game i have no errors and everything seems to look just fine. Could anyone please help me out?
this is my script
function Awake () { DontDestroyOnLoad (transform.gameObject); if( Application.loadedLevelName == "BehindLocks" ) audio.Stop(); }
Please edit and format your code. didn't you ask this yesterday? if so, you should be modifying that post, not starting a new one.
Is the AudioSource on the same object that this script is on? I'm not sure if Awake is the place to check for audio playing anyway, you might want that in Update.
I was replying to the comments but no one commented back so i decided to create a new post. And yes the AudioSource is on the same object as the script is , i also changed the Awake function to Update but it still doesn't work when in enter the scene the audio keeps playing for some reason.
Follow this Question
Related Questions
Audio Problem 0 Answers
Why my sound it's not attaching to my Flashlight 2 Answers
one shot Sound on collision. Unity 4.0 problem. 2 Answers
How to play an audio one shot clip on a collision 1 Answer
Audio Help! 1 Answer