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.
s_nuz
(snuz)
January 18, 2023, 5:45pm
#6
I have tried putting music:Stop() at the script.Parent.play.MouseButton1Click:Connect(function() but that did not seem to work either.
what i was saying was to replace the musicstop:Play() with just plain old music:Stop()
s_nuz
(snuz)
January 18, 2023, 5:53pm
#8
I did,
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()
music:Stop()
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()
script.Parent.Music:Destroy()
end)
are you experiencing any errors in output?
does everything else in the function work?
and finally, can you send a screenshot of the music’s properties as well as ( if you can ) a video of what happens when you press play?
i should have asked this first but i just was hoping for an easier solution.
s_nuz
(snuz)
January 18, 2023, 6:12pm
#10
I don’t see any errors in the output,
everything else works but that specific thing.
Jexemie
(Jeremie)
January 18, 2023, 6:23pm
#11
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
s_nuz
(snuz)
January 18, 2023, 6:26pm
#12
How would that be done? Do I destroy the music just right before the end of the whole script?
set looped to false before doing stop
something like
music.Looped = false
music:Stop()
edit: isn’t the issue, as MOVISTAR said it’s because the character reloads
another issue here, you might wanna not destroy the script.Parent and all that
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.
s_nuz
(snuz)
January 18, 2023, 7:34pm
#16
Can i add music.Looped before the script.Parent.play.MouseButton1Click:Connect(function()?
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.
s_nuz
(snuz)
January 18, 2023, 7:40pm
#18
I tested this script and it did not seem to work, it still played music. Could you tell me what’s wrong?
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()
music.Looped = true
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()
script.Parent.Music:Destroy()
end)
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.
s_nuz
(snuz)
January 18, 2023, 7:47pm
#20
Yes, the the music stops playing upon clicking the button, the fade in and out animation happens and then it plays it again.
Also I do not think I am capable of that, I am not too experienced.
game:GetService("Players").LocalPlayer.CharacterAdded:Connect(__CHARACTER)
__SOUNDHERE:Pause()
__SOUNDHERE:Destroy()
end)
Another thing, since this a kindoff main menu that only appears when you join, you should parent the script to replicatedfirst and destroy it after it’s done.
Alternative snippet that meets your code standards.
musicstop.Completed:Connect(function() music:Destroy() end)
s_nuz
(snuz)
January 18, 2023, 8:50pm
#22
After I put it into replicatedfirst and added that snippet of code you provided me everything works fine except the loading screen will not appear anymore. Instead, it’s a black screen until I load.
script.Parent.play.MouseButton1Click:Connect(function()
-- musicstop:Play()
start:Play()
start.Ended:Wait()
ftween2:Play()
musicstop.Completed:Connect(function() music:Destroy()
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)
end)
did i put everything correctly?
Just clone the gui and parent it to playergui. use WaitForChild though, objects don’t load before replicatedfirst.
system
(system)
Closed
February 1, 2023, 9:56pm
#24
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.