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

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

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

✓ Accepted answer

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.

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