SlyHades66

Chat 2

May 21st, 2016
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.84 KB | None | 0 0
  1. function onKeyPress(inputObject, gameProcessedEvent)
  2.     if inputObject.KeyCode == Enum.KeyCode.Return then
  3.     if script.Parent.Focus.Value == true then
  4.     script.Parent.Parent.Parent.msg.Value = script.Parent.Text
  5.     script.Parent.Parent.Parent.player.Value = game.Players.LocalPlayer.Name
  6.     script.Parent.Parent.Parent.RemoteEvent:FireServer()
  7.     script.Parent:ReleaseFocus()
  8.     end
  9.     elseif inputObject.KeyCode == Enum.KeyCode.Slash then
  10.         if script.Parent.Focus.Value == true then
  11.             return
  12.         else
  13.     script.Parent.Focus.Value = true
  14.     if game.Players.LocalPlayer.Character.Head:FindFirstChild("BillboardGui") then
  15.     game.Players.LocalPlayer.Character.Head.BillboardGui:Destroy()
  16.     script.Parent.Text = ""
  17.     script.Parent:CaptureFocus()
  18.     local bill = Instance.new("BillboardGui", game.Players.LocalPlayer.Character.Head)
  19.     bill.Size = UDim2.new(3, 0, 1, 0)
  20.     bill.AlwaysOnTop = true
  21.     local label = Instance.new("TextLabel", bill)
  22.     label.Size = UDim2.new(2, 0, 1, 0)
  23.     label.BackgroundColor3 = Color3.new(43, 43, 43)
  24.     label.Position = UDim2.new(-0.5, 0, -0.981, 1)
  25.     label.TextScaled = true
  26.     label.Text = ""
  27.     label.BackgroundTransparency = 0.3
  28.     label.FontSize = "Size14"
  29.     label.BackgroundColor3 = Color3.new(43, 43, 43)
  30.     else
  31.     script.Parent.Text = ""
  32.     script.Parent:CaptureFocus()
  33.     local bill = Instance.new("BillboardGui", game.Players.LocalPlayer.Character.Head)
  34.     bill.Size = UDim2.new(3, 0, 1, 0)
  35.     bill.AlwaysOnTop = true
  36.     local label = Instance.new("TextLabel", bill)
  37.     label.Text = ""
  38.     label.Size = UDim2.new(2, 0, 1, 0)
  39.     label.BackgroundColor3 = Color3.new(43, 43, 43)
  40.     label.Position = UDim2.new(-0.5, 0, -0.981, 1)
  41.     label.TextScaled = true
  42.     label.BackgroundTransparency = 0.3
  43.     label.FontSize = "Size14"
  44.     label.BackgroundColor3 = Color3.new(43, 43, 43)
  45.             end
  46.         end
  47.     end
  48. end
  49.  
  50. game:GetService("UserInputService").InputBegan:connect(onKeyPress)
  51.  
  52. script.Parent.Changed:connect(function(change)
  53.     if game.Players.LocalPlayer.Character.Head:FindFirstChild("BillboardGui") then
  54.         if game.Players.LocalPlayer.Character.Head.BillboardGui:FindFirstChild("TextLabel") then
  55.         game.Players.LocalPlayer.Character.Head.BillboardGui.TextLabel.Text = script.Parent.Text
  56.         end
  57.     end
  58. end)
  59.  
  60. script.Parent.FocusLost:connect(function(lost)
  61.     wait(0.01)
  62.     if game.Players.LocalPlayer.Character.Head:FindFirstChild("BillboardGui") then
  63.     game.Players.LocalPlayer.Character.Head.BillboardGui.TextLabel.Text = script.Parent.Text
  64.     game.Players.LocalPlayer.Character.Head.BillboardGui.TextLabel.Name = "Perm"
  65.     script.Parent.Focus.Value = false
  66.     script.Parent.Text = "Press '/' To Chat."
  67.     else
  68.     script.Parent.Focus.Value = false
  69.     script.Parent.Text = "Press '/' To Chat."
  70.         end
  71.     wait(3)
  72.     for i,v in pairs(game.Players.LocalPlayer.Character.Head:GetChildren()) do
  73.         if v.ClassName == "BillboardGui" then
  74.             if v:FindFirstChild("Perm") then
  75.             v:Destroy()
  76.             end
  77.         end
  78.     end
  79. end)
Add Comment
Please, Sign In to add comment