🎮 Scripting GUI Objects — Expanded Notes & Examples

1. Accessing GUI Elements

You can get GUI objects like this:

lua
CopyEdit
local ScreenGui = script.Parent
local TextButton = ScreenGui.TextButton
local Frame = ScreenGui.Frame
local Player = game.Players.LocalPlayer


2. Toggling Visibility Example

Use .Visible to show/hide GUI parts on button click — like your example:

lua
CopyEdit
TextButton.MouseButton1Click:Connect(function()
    if Frame.Visible then
        Frame.Visible = false
    else
        Frame.Visible = true
    end
end)

lua
CopyEdit
Frame.Visible = not Frame.Visible


3. Changing Text Dynamically

You can update button or label text based on actions:

lua
CopyEdit
TextButton.Text = "Click me!"
TextButton.MouseButton1Click:Connect(function()
    TextButton.Text = "Clicked!"
end)


4. Changing Colors and Styles

Modify colors, fonts, transparency for feedback or styling:

lua
CopyEdit
Frame.BackgroundColor3 = Color3.fromRGB(255, 0, 0)  -- Red background
TextButton.TextColor3 = Color3.fromRGB(255, 255, 255)  -- White text
TextButton.Font = Enum.Font.SourceSansBold
TextButton.TextSize = 20