Advertisement
CHoff719

spam

Jun 5th, 2019
833
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. local Player = game:GetService("Players").LocalPlayer
  2. local Character = player.Character or player.CharacterAdded:Wait() -- if player.Character doesn't exist, wait for it...
  3. local Head = Character:WaitForChild("Head")
  4. local PlayerGui = Player:WaitForChild("PlayerGui")
  5.  
  6. ------------------------------------------------------------------------
  7. -- Services
  8. local ChatService = game:GetService("Chat")
  9. local StarterGui = game:GetService("StarterGui")
  10.  
  11. ------------------------------------------------------------------------
  12. -- Initialize
  13.  
  14. local ScreenGui = Instance.new("ScreenGui", PlayerGui)
  15.  
  16. local function c3(r, g, b)
  17. return Color3.new(r/255, g/255, b/255)
  18. end
  19.  
  20. local DefaultFont = Enum.Font.SourceSans
  21. local DefaultFontSize = Enum.FontSize.Size24
  22. local DefaultColor = c3(255, 255, 255)
  23. local DefaultText = "To chat click here or press '.' key"
  24.  
  25. local Emotions = {
  26. Angry = c3(255, 0, 0),
  27. Joke = c3(0, 255, 0)
  28. }
  29.  
  30.  
  31. ------------------------------------------------------------------------
  32.  
  33. local Box = Instance.new("TextBox")
  34. Box.Font = Enum.Font.Arial
  35. Box.FontSize = Enum.FontSize.Size18
  36. Box.BackgroundTransparency = 0.6
  37. Box.TextXAlignment = Enum.TextXAlignment.Left
  38. Box.TextColor3 = c3(255, 255, 255)
  39. Box.Text = DefaultText
  40. Box.BackgroundColor3 = c3(0, 0, 0)
  41. Box.Position = UDim2.new(0, 0, 1, -24)
  42. Box.Size = UDim2.new(1, 0, 0, 24)
  43. Box.Parent = ScreenGui
  44.  
  45.  
  46. ------------------------------------------------------------------------
  47.  
  48.  
  49. Box.FocusLost:Connect(function(enterPressed)
  50. if not enterPressed then return end -- We should only send the message if enter was pressed. not if they just lost focus
  51. if not Box.Text == DefaultText then
  52. local Color = DefaultColor
  53. if Box.Text:match("*") then
  54. Color = Emotions.Joke
  55. elseif Box.Text:match("!") then
  56. Color = Emotions.Angry
  57. end
  58. StarterGui:SetCore("ChatMakeSystemMessage", {
  59. Text = "["..Player.Name.."]: "..Box.Text,
  60. Color = Color,
  61. Font = DefaultFont,
  62. FontSize = DefaultFontSize,
  63. })
  64. Chat:Chat(Head, Box.Text)
  65. end
  66. Box.Text = DefaultText
  67. end)
  68.  
  69.  
  70. Box.Focused:Connect(function()
  71. if Box.Text == DefaultText then
  72. Box.Text = "" -- If the box gets focused on and we don't already have text in there (other than the default), erase all text
  73. end
  74. end)
  75.  
  76.  
  77. game:GetService("UserInputService").InputBegan:connect(function(value, bool)
  78. if not bool then
  79. if value.KeyCode == Enum.KeyCode.Slash then -- keep it user-friendly and don't change settings up on them
  80. Box:CaptureFocus()
  81. end
  82. end
  83. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement