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

Visible on click?

Asked by
Uroxus 350 Moderation Voter
10 years ago

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

Log in to vote
0
Answered by 10 years ago

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)
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 VariadicFunction 335 — 10y
0
Hi! Thank you for your reply! It does work for the first part (It opens) but it dosent close... Uroxus 350 — 10y
Ad

Answer this question