I'm a beginner in scripting, i looked up how to add sound to your game on Youtube, and it said the typical LocalScript and put it in the StarterGui, i did, and the sounds i use are used for sound effects for certain things, so when i died in my game all my sound effects replayed, where do i put the sound script to make it not play again when a player dies
It's commonly said that LocalScripts are to be placed within StarterGui
. However, this is actually a bad practice. Scripts should be placed within the parent
that is most related to whatever it's functional purpose is supposed to be; therefore, Scripts for GUIs, should only be placed within that folder.
The reason for this mistake is because StarterGui
replicates all descendants to the Client
, in a folder called PlayerGui
. Since this folder is a Client service, LocalScripts can run within them.
For general purpose programs, they should be placed within a folder called: StarterPlayerScripts
, this won't disrupt any running programs or cause the issues you're experiencing, while still allowing LocalScripts to run, as it too, is a Client service. To fix your issue, move it to that folder.
StarterPlayerScripts
can be found under the StarterPlayer
folder.
Turn off the ResetOnSpawn value on the Gui (by using the properties tab) Steps: Go to your GUI --> Find the "ResetOnSpawn" value (has a checkbox beside it) on your explorer --> Turn the value off (checkbox)