What do you want to achieve? Keep it simple and clear!
I want the sound to stop playing after I click the play button, I also want to switch thru cams in the menu.
What is the issue? Include screenshots / videos if possible!
The sound keeps playing in game after clicking the play button.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried destroying the sound, stopping it, muting it… none of these seem to work!
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local fade = script.Parent.Fade
local music = script.Parent.Music
local start = script.Parent.Start
local TS = game:GetService("TweenService")
local ftween = TS:Create(fade, TweenInfo.new(5), {BackgroundTransparency = 1})
local ftween2 = TS:Create(fade, TweenInfo.new(2.5), {BackgroundTransparency = 0})
local musicstop = TS:Create(music, TweenInfo.new(1), {Volume = 0})
workspace.ambience.negativeambience:Pause()
local random = math.random(1,6)
local camera = workspace.camCFrames["cam"..random]
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera.CFrame = camera.CFrame
local respawnevent = game.ReplicatedStorage.Respawn
game:GetService("Players").LocalPlayer.CameraMaxZoomDistance = 15
game:GetService("Players").LocalPlayer.CameraMinZoomDistance = 15
repeat wait() until game:IsLoaded()
music:Play()
wait(2.5)
ftween:Play()
script.Parent.play.MouseButton1Click:Connect(function()
musicstop:Play()
start:Play()
start.Ended:Wait()
ftween2:Play()
wait(5)
game.SoundService.AmbientReverb = Enum.ReverbType.UnderWater
game.Lighting.MenuBlur.Enabled = true
fade.BackgroundTransparency = 1
script.Parent.Loading.Visible = true
script.Parent.Title.Visible = false
script.Parent.play.Visible = false
script.Parent.credits.Visible = false
script.Parent.settings.Visible = false
music.Playing = false
wait(10)
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
game.SoundService.AmbientReverb = Enum.ReverbType.ParkingLot
game.Lighting.MenuBlur.Enabled = false
workspace.ambience.negativeambience:Resume()
respawnevent:FireServer(game.Players.LocalPlayer)
script.Parent:Destroy()
end)
I also have a localscript inside that localscript that switches between the cams,
while true do
local random = math.random(1,6)
local camera = workspace.camCFrames["cam"..random]
workspace.CurrentCamera.CFrame = camera.CFrame
wait(5)
end
interesting issue, i believe your issue might be the tween service? i’ve never seen that type of way to stop music before. it might be easier to just give up on a smooth transition out of music and just do
music:Stop()
again i believe your issue is with how you try to tween the volume to 0.
Maybe… because the character spawns again after pressing the play button and the music keeps is playing? only do music:Play() when the player is in the loading screen, not in the actual game
The issue is that the Looped property is already enabled before running the game, so whenever your character is (re)spawned, the sound will automatically play. You have to disable the Looped property manually, not in a script.
After you disable Loooped, you may still tween the volume of the sound if you’d like, but you need to play the sound when the player first joins.
Yes, you may set the Looped property to true in the script, no problem. Just keep the Looped property set to false from the properties tab before running the game.
So just to be clear, the sound does stop playing when you click the button, but when you respawn, the sound will start playing again, is that correct? If so, I believe this is because this script continues to run even after respawning, which even runs the music.Looped = true code line.
I think you need to find a way to disable the script, or find a way to check if the player is currently in the menu or not.
If you have something to check if the player is in the menu or not, make an if statement to check if the player is currently in menu, then it will set Looped to true, and vice versa.