Sound won't play in GUI

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 
		MainFrame.Visible = true --frame becomes visible
	elseif --elseif -->
		MainFrame.Visible == true then --frame is visibe then 
		MainFrame.Visible = false --frame.Visible = false
1 Like

if it’s a sound then instead of



.Playing = true

If that doesn’t work then I am no longer helpful.

You could parent it to game:GetService("SoundService") instead as I don’t think sounds play when parented to GUI.

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")

	if MainFrame.Visible then
		MainFrame.Visible = false
		MainFrame.Visible = true
1 Like

This warning means that the script waited 5 seconds for the Instance and did not find anything.

Remember script.Parent will get the Instance where the script is inside, so check if you’re localizing “InfoOpen” and “Select” correctly.

NVM i fixed it myself by scripting something else lol