How can I make music play for my main menu gui?

I need replace which part with script.Parent.ExitButton? Because atm its still doing the same thing

Have you tried what I posted earlier?

Yes, It didnt play and also broke the play button again.

Yes, here is an example:
My gui:
image

In this case, ExitButtom would be Close:

local Sound = Instance.new("Sound",script)
Sound.SoundId = "rbxassetid://" .. 0

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent.Visible = false
    Sound:Play()
end)

local ExitButtom = script.Parent.Parent.Close
ExitButtom.MouseButton1Click:Connect(function()
    Sound:Stop()
end)

Have you inserted the sound id into the script?

So what would I put there in my case? “Play”?

Yes, It still held the same results.

Wait, you want a play button to make a frame visible and play a sound?

No, clicking the play button is supposed to make the music stop.

It would be Play, right?

local Sound = Instance.new("Sound",script)
Sound.SoundId = "rbxassetid://" .. 0
Sound:Play()
Sound.Looped = true

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent.Visible = false
    Sound:Stop()
end)

Since it doesn’t have a button to start the sound, it is placed outside of Connect for it to play.
(Add Looped so it doesn’t stop.)

1 Like

Alright! Check this.

--// Variables //--
local Button = script.Parent
local Frame = script.Parent.Parent
local Sound = script.Parent.Parent:WaitForChild("Sound")
Sound.SoundId = "rbxassetid://" .. ID

--// Functions //--
Button.MouseButton1Click:Connect(function()
	Frame.Visible = false
	Sound:Stop()
end)
1 Like

Yes, this worked, thank you so much!

1 Like

You’re welcome, happy to help ^ - ^

Ah, this worked too, I’d mark you as solution but SOTR654’s worked and she posted hers first, I still very much appreciate your help.

2 Likes