I wanted the music to play when I open menu back but it doesn’t play.
I tried using the infinite loop but I didn’t know how to do it?
-- MusicScript, also a LocalScript, this is not combined with the other LocalScript
music = script.Parent.MenuMusic
Button = script.Parent.Deploy
music:Play()
Button.MouseButton1Click:Connect(function()
music:Stop()
end)
-- Local Script
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.MainMenu.Visible = true
end)
while true do
music = script.Parent.MenuMusic
music = script.Parent.Parent.MainMenu
music:Play()
script.Parent.MouseButton1Click:Connect(function()
music:Stop()
end)
end
LocalScript is combined with OpenMenuGui shown in the vid. MusicScript is with the MainMenu. I use the Deploy Button to get out of the menu and I use the Open Menu Button to get back in the Menu.
script.Parent.MouseButton1Click:Connect(function()
menu.Enabled = not menu.Enabled --initially true
music.Playing = not music.Playing --initially true
end
Do I put this in the MusicScript or LocalScript? Do I keep my infinite loop in the script? Check the edit of my post if you didn’t know which one was LocalScript or MusicScript. Oh I forgot to say the LocalScript is combined with the OpenMenuGui shown in the vid.
Remove the button connection block and the music:Stop() from the music script, and let the localscript toggle the music and menu both! You can also remove the while true do loop, as the new connection function I supplied will toggle it every time you press the button. Essentially, you’re letting the server script play the music and enable the menu. Then the localscript toggles both locally! Sorry for the confusion, both should be initially true.
I forgot to say the MusicScript is also a LocalScript. When I added it, it isn’t working because the music isn’t stopping and I can’t open back the open menu button. I forgot to say I use the Deploy Button to get out of the menu, and then I use the Open Menu Button to get back into the Menu. Here is the LocalScript.
Space
–LocalScript, not combined with the DeployLocalScript
local menu = script.Parent.Parent.OpenMenuGui
local music = script.Parent.MenuMusic
script.Parent.MouseButton1Click:Connect(function()
ddddmenu.Enabled = not menu.Enabled --initially true
ddddmusic.Playing = not music.Playing --initially true
end)
Still not working, the menu is still there. Forgot to say I put the DeployButton in the MainMenu, the MainMenu is inside MenuGui, and I put the Open Menu Button in the MenuGui.
-- menu/music localscript
local menu = script.Parent.Parent.OpenMenuGui
local music = script.Parent.MenuMusic
menu.Enabled = true
music:Play()
script.Parent.MouseButton1Click:Connect(function()
menu.Enabled = not menu.Enabled --initially true
music.Playing = not music.Playing --initially true
end)
-- deploy localscript
local music = script.Parent.Parent.MenuMusic
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Enabled = false -- edit is here from 3 parents to 2!
music:Pause()
end)
Yes the button that takes you back to the menu, is it’s visibility being marked as false?
If not then is the ScreenGui that houses the button being disabled?