-- LOCALSCRIPT: Fully Local Roblox-Style Chat local Players = game:GetService("Players") local player = Players.LocalPlayer -- ===== CREATE SCREEN GUI ===== local gui = Instance.new("ScreenGui") gui.Name = "LocalChatGUI" gui.ResetOnSpawn = false gui.Parent = player:WaitForChild("PlayerGui") -- ===== CHAT BUTTON (BOTTOM-RIGHT) ===== local chatButton = Instance.new("TextButton") chatButton.Size = UDim2.new(0,50,0,50) chatButton.Position = UDim2.new(1,-60,1,-60) chatButton.AnchorPoint = Vector2.new(0,0) chatButton.BackgroundColor3 = Color3.fromRGB(40,40,40) chatButton.TextColor3 = Color3.new(1,1,1) chatButton.Text = "Chat" chatButton.TextScaled = true chatButton.Font = Enum.Font.SourceSansBold chatButton.BorderSizePixel = 0 chatButton.Parent = gui -- ===== CHAT FRAME ===== local chatFrame = Instance.new("Frame") chatFrame.Size = UDim2.new(0,300,0,200) chatFrame.Position = UDim2.new(1,-310,1,-260) chatFrame.BackgroundColor3 = Color3.fromRGB(20,20,20) chatFrame.BorderSizePixel = 0 chatFrame.Visible = false chatFrame.Parent = gui -- Scrolling messages local scrolling = Instance.new("ScrollingFrame") scrolling.Size = UDim2.new(1,0,1,-30) scrolling.Position = UDim2.new(0,0,0,0) scrolling.BackgroundTransparency = 1 scrolling.BorderSizePixel = 0 scrolling.CanvasSize = UDim2.new(0,0,0,0) scrolling.ScrollBarThickness = 6 scrolling.Parent = chatFrame local layout = Instance.new("UIListLayout") layout.SortOrder = Enum.SortOrder.LayoutOrder layout.Padding = UDim.new(0,4) layout.Parent = scrolling -- Input box local box = Instance.new("TextBox") box.Size = UDim2.new(0,240,0,22) box.Position = UDim2.new(0,5,1,-25) box.PlaceholderText = "Type a message..." box.BackgroundColor3 = Color3.fromRGB(25,25,25) box.TextColor3 = Color3.new(1,1,1) box.BorderSizePixel = 0 box.TextSize = 14 box.Parent = chatFrame -- Send button local send = Instance.new("TextButton") send.Size = UDim2.new(0,50,0,22) send.Position = UDim2.new(0,250,1,-25) send.Text = "Send" send.BackgroundColor3 = Color3.fromRGB(40,40,40) send.TextColor3 = Color3.new(1,1,1) send.BorderSizePixel = 0 send.TextSize = 14 send.Parent = chatFrame -- ===== TOGGLE CHAT ===== chatButton.MouseButton1Click:Connect(function() chatFrame.Visible = not chatFrame.Visible if chatFrame.Visible then box:CaptureFocus() end end) -- ===== FUNCTION TO DISPLAY MESSAGE ===== local function displayMessage(senderName, text) -- Add message to GUI local msg = Instance.new("TextLabel") msg.Size = UDim2.new(1,-10,0,20) msg.BackgroundTransparency = 0.5 msg.BackgroundColor3 = Color3.fromRGB(0,0,0) msg.TextColor3 = Color3.fromRGB(255,255,255) msg.TextWrapped = true msg.TextScaled = true msg.Font = Enum.Font.SourceSansBold msg.Text = senderName .. ": " .. text msg.Parent = scrolling scrolling.CanvasSize = UDim2.new(0,0,0,layout.AbsoluteContentSize.Y) -- Show message above your head if player.Character and player.Character:FindFirstChild("Head") then local head = player.Character.Head if head:FindFirstChild("LocalChatMsg") then head.LocalChatMsg:Destroy() end local bill = Instance.new("BillboardGui") bill.Name = "LocalChatMsg" bill.Size = UDim2.new(0,220,0,40) bill.StudsOffset = Vector3.new(0,2.5,0) bill.AlwaysOnTop = true bill.Parent = head local label = Instance.new("TextLabel") label.Size = UDim2.new(1,0,1,0) label.BackgroundTransparency = 0.5 label.BackgroundColor3 = Color3.fromRGB(0,0,0) label.TextColor3 = Color3.fromRGB(255,255,255) label.TextScaled = true label.Font = Enum.Font.SourceSansBold label.TextWrapped = true label.Text = senderName .. ": " .. text label.Parent = bill -- Remove after 30 seconds task.delay(30, function() if bill then bill:Destroy() end end) end end -- ===== SEND MESSAGE ===== local function sendMessage() if box.Text ~= "" then displayMessage(player.Name, box.Text) box.Text = "" end end send.MouseButton1Click:Connect(sendMessage) box.FocusLost:Connect(function(enter) if enter then if enter then sendMessage() end end end)