Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Please help with this simple GUI script?

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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.

Ad

Answer this question