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

My open/close gui not working as i expected? it wont close again what did i do wrong?

Asked by
hokyboy 270 Moderation Voter
5 years ago

My open/close gui not working as i expected? it wont close again what did i do wrong?

script.Parent.MouseButton1Click:Connect(function()
        if script.Parent.Parent.Value.Value == true then
        script.Parent.Parent.Size = UDim2.new(1, 0, 0, 50)
    script.Parent.Parent.Play.Visible = false
    script.Parent.Parent.c.Visible = false
    script.Parent.Parent.d.Visible = false
    script.Parent.Text = "Rainbow Road  ?"
    script.Parent.Parent.Value.Value = false
    end



    if script.Parent.Parent.Value.Value == false then 
    script.Parent.Parent.Size = UDim2.new(1, 0, 0, 200)
    script.Parent.Parent.Play.Visible = true
    script.Parent.Parent.c.Visible = true
    script.Parent.Parent.d.Visible = true
    script.Parent.Text = "Rainbow Road ?"
    script.Parent.Parent.Value.Value = true
    end
end)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Ok, buddy, many issues with this. First of all, please indent. The indentation on this is not good. Next, this is way more complicated then it has to be. Next, use 'Activated' instead of MouseButton1Click, so if a phone clicks the button, it still works.

script.Parent.Activated:Connect(function()
    if script.Parent.Parent.Value.Value == true then
        script.Parent.Parent.Size = UDim2.new(1, 0, 0, 50)
        script.Parent.Parent.Play.Visible = false
        script.Parent.Parent.c.Visible = false
        script.Parent.Parent.d.Visible = false
        script.Parent.Text = "Rainbow Road"
        wait("insert wait time here")
        script.Parent.Parent.Value.Value = false
    else
        script.Parent.Parent.Size = UDim2.new(1, 0, 0, 200)
        script.Parent.Parent.Play.Visible = true
        script.Parent.Parent.c.Visible = true
        script.Parent.Parent.d.Visible = true
        script.Parent.Text = "Rainbow Road"
        wait("insert wait time here")
        script.Parent.Parent.Value.Value = true
    end
end)

The simple fix is the else command.

Ad

Answer this question