local ChatGui = Instance.new("ScreenGui")
local Frame = Instance.new("Frame")
local LogPanel = Instance.new("ScrollingFrame")
local Close = Instance.new("TextButton")
local Mini = Instance.new("TextButton")
local Log = Instance.new("TextButton")
local title = Instance.new("TextLabel")
local UIListLayoutt = Instance.new("UIListLayout", LogPanel)
UIListLayoutt.VerticalAlignment = "Bottom"
UIListLayoutt.Padding = UDim.new(0, 0) 
ChatGui.Name = "ChatGui"
ChatGui.Parent = game.Players.LocalPlayer.PlayerGui
ChatGui.ResetOnSpawn = false
Frame.Parent = ChatGui
Frame.BackgroundColor3 = Color3.new(0, 0, 0)
Frame.BorderSizePixel = 0
Frame.Position = UDim2.new(0.0278396439, 0, 0.565217376, 0)
Frame.Size = UDim2.new(0, 600, 0, 400) 
Frame.Active = true
Frame.Draggable = true
LogPanel.Name = "LogPanel"
LogPanel.Parent = Frame
LogPanel.BackgroundColor3 = Color3.new(0, 0, 0)
LogPanel.BorderColor3 = Color3.new(0.223529, 0.223529, 0.223529)
LogPanel.Position = UDim2.new(0, 0, 0.0625, 0) 
LogPanel.Size = UDim2.new(1, 0, 0.875, 0) 
LogPanel.ScrollBarThickness = 5
LogPanel.ScrollingEnabled = true
LogPanel.CanvasSize = UDim2.new(2, 0, 100, 0)
Close.Name = "Close"
Close.Parent = Frame
Close.BackgroundColor3 = Color3.new(1, 1, 1)
Close.BackgroundTransparency = 1
Close.Position = UDim2.new(0.823979557, 0, 0, 0) 
Close.Size = UDim2.new(0.176020443, 0, 0.0625, 0) 
Close.Font = Enum.Font.SourceSans
Close.Text = "Close"
Close.TextColor3 = Color3.new(1, 1, 1)
Close.TextSize = 14
Mini.Name = "Mini"
Mini.Parent = Frame
Mini.BackgroundColor3 = Color3.new(1, 1, 1)
Mini.BackgroundTransparency = 1
Mini.Position = UDim2.new(0.647959173, 0, 0, 0)
Mini.Size = UDim2.new(0.176020443, 0, 0.0625, 0) 
Mini.Font = Enum.Font.SourceSans
Mini.Text = "Minimize"
Mini.TextColor3 = Color3.new(1, 1, 1)
Mini.TextSize = 14
Log.Name = "Log"
Log.Parent = Frame
Log.BackgroundColor3 = Color3.new(1, 1, 1)
Log.BackgroundTransparency = 1
Log.Position = UDim2.new(0.293367326, 0, 0, 0) 
Log.Size = UDim2.new(0.354591837, 0, 0.0625, 0) 
Log.Font = Enum.Font.SourceSans
Log.Text = "Log Chat [ON]"
Log.TextColor3 = Color3.new(1, 1, 1)
Log.TextSize = 14
title.Name = "title"
title.Parent = Frame
title.BackgroundColor3 = Color3.new(1, 1, 1)
title.BackgroundTransparency = 1
title.Size = UDim2.new(0.293367326, 0, 0.0625, 0)
title.Font = Enum.Font.SourceSans
title.Text = "Syr0nix Chat GUI"
title.TextColor3 = Color3.new(1, 1, 1)
title.TextSize = 14
title.TextXAlignment = Enum.TextXAlignment.Left
local ChatBox = Instance.new("TextBox")
ChatBox.Name = "ChatBox"
ChatBox.Parent = Frame
ChatBox.Size = UDim2.new(1, 0, 0.0625, 0) 
ChatBox.Position = UDim2.new(0, 0, 0.9375, 0) 
ChatBox.PlaceholderText = "Type your message here..."
ChatBox.ClearTextOnFocus = false
ChatBox.Font = Enum.Font.SourceSans
ChatBox.TextSize = 14
ChatBox.TextColor3 = Color3.new(1, 1, 1)
ChatBox.BackgroundTransparency = 0.5
ChatBox.BackgroundColor3 = Color3.new(0, 0, 0)
ChatBox.BorderSizePixel = 0
local logging = true
local minimized = false
Log.MouseButton1Down:Connect(function()
    logging = not logging
    if logging then Log.Text = "Log Chat [ON]" else Log.Text = "Log Chat [OFF]" end
end)
Mini.MouseButton1Down:Connect(function()
    if minimized then
        LogPanel:TweenSize(UDim2.new(0, 600, 0, 350), "InOut", "Sine", 0.5, false, nil)
    else
        LogPanel:TweenSize(UDim2.new(0, 600, 0, 0), "InOut", "Sine", 0.5, false, nil)
    end
    minimized = not minimized
end)
Close.MouseButton1Down:Connect(function()
    ChatGui:Destroy()
end)
local prevOutputPos = 0
function output(plr, msg)
    if not logging then return end
    local colour = Color3.fromRGB(255, 255, 255)
    if string.sub(msg, 1, 1) == ":" or string.sub(msg, 1, 1) == ";" then
        colour = Color3.fromRGB(255, 0, 0)
    elseif string.sub(msg, 1, 2) == "/w" or string.sub(msg, 1, 7) == "/whisper" or string.sub(msg, 1, 5) == "/team" or string.sub(msg, 1, 2) == "/t" then
        colour = Color3.fromRGB(0, 0, 255)
    else
        colour = Color3.fromRGB(255, 255, 255)
    end
    local o = Instance.new("TextLabel", LogPanel)
    o.Text = plr.Name .. ": " .. msg
    o.Size = UDim2.new(0.5, 0, .003, 0)
    o.Position = UDim2.new(0, 0, .007 + prevOutputPos, 0)
    o.Font = Enum.Font.SourceSansSemibold
    o.TextColor3 = colour
    o.TextStrokeTransparency = 0
    o.BackgroundTransparency = 0
    o.BackgroundColor3 = Color3.new(0, 0, 0)
    o.BorderSizePixel = 0
    o.BorderColor3 = Color3.new(0, 0, 0)
    o.FontSize = "Size14"
    o.TextXAlignment = Enum.TextXAlignment.Left
    o.ClipsDescendants = true
    prevOutputPos = prevOutputPos + 0.003
end
for i, v in pairs(game.Players:GetChildren()) do
    v.Chatted:Connect(function(msg)
        output(v, msg)
    end)
end
game.Players.ChildAdded:Connect(function(plr)
    if plr:IsA("Player") then
        plr.Chatted:Connect(function(msg)
            output(plr, msg)
        end)
    end
end)
ChatBox.FocusLost:Connect(function(enterPressed)
    if enterPressed then
        local message = ChatBox.Text
        ChatBox.Text = "" 
        game.ReplicatedStorage.DefaultChatSystemChatEvents.SayMessageRequest:FireServer(message, "All")
    end
end)

-- Focus ChatBox when / key is pressed
game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed)
    if input.KeyCode == Enum.KeyCode.Slash and not gameProcessed then
        ChatBox:CaptureFocus()
    end
end)