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

Open/Close code won't work with chat button, can you help me? [Custom gui]

Ok, so, I'm trying to make a chat button on the topbar but the visible code won't work, I need help

local ChatButton = script.Parent.Bar:WaitForChild("Chat")
local ChatTarget = script.Parent.Parent.Parent.Chat.Frame

ChatButton.MouseButton1Click:connect(function()
	if ChatTarget.Visible then
		ChatTarget.Visible=false
	else
		ChatTarget.Visible=true
	end
end)

3 comments

0

Are you getting any errors in the output box? If you are, could you type them here? Also, instead of using "connect" in line 4, use "Connect" instead. "connect" is deprecated and ROBLOX might delete it soon, so make sure you capitalize the "c".

0

Also, what's the point of the "if" statement on line 5? What is this checking for exactly? Is it checking for "Visible" as in the property? Because I am unsure if you can use an "if" statement to check if a property exists. If this is what you are trying to use it for, I don't think there is a reason for it anyway. Did you maybe mean to type "if ChatTarget.Visible == true then"?

0

I have a similar code in GUI but FE broke it

1 answer

###I don’t know why it doesn’t work. It should.

ChatButton.MouseButton1Click:Connect(function()
    ChatTarget.Visible = not ChatTarget.Visible
    print"Gui toggled!" --Add a print to make sure its working. 
end)

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