This sound won’t play in the GUI, there are no errors in the console. Its supposed to be like the sound that plays when you push the button. The code is not mine
local branch = script.Parent --Variable points to ScreenGui & everthing inside/below it.
local open = branch["InfoOpen"] --Variable points to the open/close button.
local MainFrame = branch.Frame --Variable points to "Frame".
open.MouseButton1Click:connect(function() --Anonymous function that is wired to the open/close button.
if MainFrame.Visible == false then --If Frame isn't Visible then
script.Parent.Select:Play()
MainFrame.Visible = true --frame becomes visible
elseif --elseif -->
MainFrame.Visible == true then --frame is visibe then
MainFrame.Visible = false --frame.Visible = false
end
end)
Your code was a little messy, I optimized it for you:
local branch = script.Parent
local button = branch:WaitForChild("InfoOpen")
local MainFrame = branch:WaitForChild("Frame")
local Sound = branch:WaitForChild("Select")
button.Activated:Connect(function()
if MainFrame.Visible then
MainFrame.Visible = false
else
MainFrame.Visible = true
Sound:Play()
end
end)