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

Visible on click?

Im trying to make a chat box that you can only see and type in this GUI im making. I have the basic layout:

StarterGui - ScreenGui(Named Global) - TextButton(Named General) - LocalScript and ScrollableFrame and in the frame a TextBox.

I need the TextButton (General) to be the one that toggles the Frame which then visible = true on TextBox...

Heres my code thats in the local script.

local scriptParent = game.StarterGui.GlobalChat.General
local ToggleButton = game.StarterGui.GlobalChat.General
local chatbox = game.StarterGui.GlobalChat.General.ChatBox
local chattype = game.StarterGui.GlobalChat.General.ChatType


ToggleButton.MouseButton1Down:connect(function()
	if chatbox.Visible then
		chatbox.Visible = false
	else
		chatbox.Visible = true
	end
end)
	

Thanks :)

1 answer

You can't use things StarterGui as a valid way for events and what not. The GUI in StarterGui is cloned into the player's GUIs so doing an event for when something is clicked in the StarterGui will have no effect.

local general = script.Parent --General is the scripts parent so you can just do this
local chatbox = general.ChatBox

general.MouseButton1Click:connect(function()
	if chatbox.Visible == true then
		chatbox.Visible = false
	else
		--Can only be true or false, so if not true, then it has to be false
		chatbox.Visible = true
	end
end)

2 comments

0

Not sure if this is what you were asking for and I can't test it really, but I attempted to fix the code up however I could

0

Hi! Thank you for your reply! It does work for the first part (It opens) but it dosent close...

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