Er1x_Official

Custom Chat Local Script

May 8th, 2022
941
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. local rep = game:GetService("ReplicatedStorage")
  2. local chatted = rep:WaitForChild("Chatted")
  3.  
  4. local uis = game:GetService("UserInputService")
  5. local deb = game:GetService("Debris")
  6.  
  7. local par = script.Parent
  8. repeat task.wait(.1) until par:FindFirstChild("Frame")
  9. local Box,Chat = par.Frame:FindFirstChild("Box"), par.Frame:FindFirstChild("Chat")
  10. local Focus = Enum.KeyCode.Slash -- "/" key
  11.  
  12. uis.InputEnded:Connect(function(input,x)
  13.     if not x then
  14.         if input.KeyCode == Focus then
  15.             task.wait()
  16.             Chat:CaptureFocus() -- focus to the textbox
  17.         end
  18.     end
  19. end)
  20.  
  21. Chat.FocusLost:Connect(function(Enter)
  22.     if Enter then -- check if Enter was pressed
  23.         chatted:FireServer(Chat.Text)
  24.         Chat:ReleaseFocus() -- release textbox focus
  25.         Chat.Text = "" -- clear textbox
  26.     end
  27. end)
  28.  
  29. chatted.OnClientEvent:Connect(function(String)
  30.     if typeof(String) == "string" then -- check if its a string or not
  31.         local temp = Box:WaitForChild("Temp"):Clone()
  32.         temp.Parent = Box
  33.         temp.Visible = true
  34.         temp.LayoutOrder = #Box:GetChildren()
  35.         temp.Text = String
  36.         deb:AddItem(temp,300) -- clean up
  37.     end
  38. end)
Advertisement
Add Comment
Please, Sign In to add comment