Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Please help with this simple GUI script?

Hello everyone, today I was trying to make a button that opens another Gui, like a shop. I want it to have 3 purposes, like if the Gui is visible it will become not invisible, then if it is invisible it will become visible, Like open and closing. Also I tried to make it play a sound when you click on it but nothing works, please help if you can!

function die()
if script.Parent.ImageLabel.Visible = true 
script.Parent.ImageLabel.Visible = false
else
script.Parent.ImageLabel.Visible = true
Game.Workspace.StarterGui.Sound3:Play()
end
script.Parent.MouseButton1Down:connect(die)

1 answer

I think you need a true or false value to make it work. This is made assumed that the Image Label is already visible.

local enabled = true
function die()
if enabled == true then
script.Parent.ImageLabel.Visible = false
else
script.Parent.ImageLabel.Visible = true
Game.Workspace.StarterGui.Sound3:Play()
end
script.Parent.MouseButton1Down:connect(die)

I typed this on the fly so I am not sure if it will fully work, but I am confident it will work.

This discussion is preserved as it was. New answers, comments, and votes are closed.