So I was making some music in the main menu thing and when you press play the music is supposed to be disabled so you will not hear it again but when I reset my character the music plays even though im not in menu and I disabled it with a script
I tried deleting the sound which did not work at all and I hope someone can help me out
When the character respawns, all of the gui resets, this means the script plays the music again, and it stops working because the main menu doesn’t exist anymore. Put the script in StarterPlayerScripts to solve the issue.
…why not just call Stop on the sound object? Knowing your implementation (code and screenshots of your object hierarchy) would be very valuable here.
Instead of doing that, put the music outside of the GUI, perhaps in ReplicatedStorage.
In your script:
if not game.Workspace.CurrentCamera:FindFirstChild( 'Music' ) then
local music = game.ReplicatedStorage.Music:Clone()
music.Parent = game.Workspace.CurrentCamera
music:Play()
end
And then later on when you want to stop it…
-- inside your click handler:
local music = game.Workspace.CurrentCamera:FindFirstChild( 'Music' )
if music then
music:Stop()
end
The music in your camera shouldn’t be reset when you die, therefore it doesn’t play again as the script can see you’ve already got a music in there.