Prehistoricman

Roblox chat GUI

Aug 23rd, 2013
11,453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.38 KB | None | 0 0
  1. clone = script.Parent.Default:Clone()
  2.  
  3. --------------------------------------
  4. fontsize = 18
  5. buffer = 3
  6. lines = 6
  7.  
  8. linesize = fontsize + buffer * 2
  9. script.Parent.Size = UDim2.new(0.3, 0, 0, linesize * lines)
  10. script.Parent.Default.Position = UDim2.new(0, 0, 0, linesize * lines - linesize)
  11. script.Parent.Default.FontSize = "Size"..fontsize
  12. --------------------------------------
  13.  
  14. ranks = {   [1] = "Enlist",
  15.             [2] = "Private",
  16.             [3] = "Corporal",
  17.             [4] = "Sergeant",
  18.             [5] = "Staff Sergeant",
  19.             [6] = "First Sergeant",
  20.             [7] = "Sergeant Major",
  21.             [8] = "Warrant Officer",
  22.             [9] = "Second Lieutenant",
  23.             [10] = "First Lieutenant",
  24.             [11] = "CiT",
  25.             [12] = "DP",
  26.             [12+1] = "Captain",
  27.             [13+1] = "Major",
  28.             [14+1] = "Colonel",
  29.             [15+1] = "Major General",
  30.             [16+1] = "Lieutenant General",
  31.             [17+1] = "General",
  32.             [18+1] = "Commander"
  33. }
  34.  
  35. function shiftup()
  36.     for _, a in pairs(script.Parent:GetChildren()) do
  37.         if a.Name == "Chat" then
  38.             shared[a].True = shared[a].True + UDim2.new(0, 0, 0, -linesize)
  39.             a:TweenPosition(shared[a].True, "Out", "Quad", 0.157, true)
  40.         end
  41.     end
  42. end
  43. function Chat(msg, plr, rankoverride)
  44.     shiftup()
  45.     local text = clone:Clone()
  46.     text.Visible = true
  47.     text.Text = msg
  48.     text.Name = "Chat"
  49.     if plr:IsInGroup(226584) or rankoverride then
  50.         if not rankoverride then
  51.             local rank = Player:GetRankInGroup(226584)
  52.         else
  53.             rank = rankoverride
  54.         end
  55.         text.Text = "["..ranks[rank].."] "..plr.Name..": "..text.Text
  56.         if rank >= 13 then
  57.             text.TextColor3 = Color3.new(0, 0, 127/225)
  58.         else
  59.             text.TextColor3 = Color3.new(28/225, 43/225, 1)
  60.         end
  61.     else
  62.         text.Text = "[Visitor] "..plr.Name..": "..text.Text
  63.     end
  64.     text.Position = text.Position + UDim2.new(0, 0, 0, linesize)
  65.     text.Parent = script.Parent
  66.     text:TweenPosition(UDim2.new(0, 0, 0, linesize * lines - linesize), "Out", "Quad", 0.157, true)
  67.     shared[text] = {}
  68.     shared[text].True = UDim2.new(0, 0, 0, linesize * lines - linesize)
  69.     Lines = text.TextBounds.Y / fontsize --18 is the font size
  70.     for i = 1, Lines - 1 do
  71.         shiftup()
  72.     end
  73.     text.Size = UDim2.new(1, 0, 0, linesize * Lines)
  74.     game:GetService("Debris"):AddItem(text, 60)
  75. end
  76.  
  77. game.Players.PlayerAdded:connect(function (plr)
  78.     plr.Chatted:connect(function (m)
  79.         Chat(m, plr)
  80.     end)
  81. end)
  82.  
  83. for _, plr in pairs(game.Players:GetChildren()) do
  84.     plr.Chatted:connect(function (m)
  85.         Chat(m, plr)
  86.     end)
  87. end
  88.  
  89. _G.chat = Chat
Advertisement
Add Comment
Please, Sign In to add comment