Advertisement
Guest User

Custom Chat - Full Code

a guest
Nov 17th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.58 KB | None | 0 0
  1. function C3(r,g,b)
  2.     return Color3.new(r/255,g/255,b/255)
  3. end
  4.  
  5. local Settings = {
  6.     ["GameName"] = "the game";
  7.     ["ConsoleName"] = "SERVER";
  8.     ["ConsoleColor"] = C3(0,192,128);
  9.     ["WelcomeMessage"] = true;
  10.     ["PlayerJoinMessage"] = true;
  11.     ["PlayerLeaveMessage"] = true;
  12.     ["RandomChatColor"] = true;
  13.     ["DefaultChatColor"] = C3(192,192,192);
  14.     ["ChatColors"] = {
  15.         C3(192,192,192);
  16.         C3(32,192,32);
  17.         C3(16,192,192);
  18.         C3(255,32,32);
  19.         C3(64,64,255);
  20.         C3(255,96,255);
  21.         C3(255,16,255);
  22.         C3(255,255,64);
  23.     }
  24. }
  25.  
  26. function addMessage(speaker,msg,chat,color)
  27.     for i,v in pairs(chat:GetChildren()) do
  28.         if v:IsA("Frame") and string.sub(v.Name,1,7) then
  29.             v.ActualPosition.Value = v.ActualPosition.Value-32
  30.             v:TweenPosition(UDim2.new(0,5,0,v.ActualPosition.Value),"Out","Sine",0.5,true)
  31.             v.Name = "Message"..tostring(tonumber(string.sub(v.Name,8))+1)
  32.             if v.Name == "Message6" then
  33.                 v:TweenPosition(UDim2.new(0,5,0,-62),"Out","Sine",0.5,true)
  34.                 game:GetService("Debris"):AddItem(v,0.5)
  35.             end
  36.         end
  37.     end
  38.     local ChatFrame = Instance.new("Frame",chat)
  39.     ChatFrame.Name = "Message1"
  40.     ChatFrame.BackgroundTransparency = 1
  41.     ChatFrame.Position = UDim2.new(0,5,0,149)
  42.     ChatFrame.Size = UDim2.new(0,0,0,32)
  43.     local ActualPosition = Instance.new("IntValue",ChatFrame)
  44.     ActualPosition.Name = "ActualPosition"
  45.     ActualPosition.Value = 149
  46.     local Name = Instance.new("TextLabel",ChatFrame)
  47.     Name.Name = "Name"
  48.     Name.BackgroundTransparency = 1
  49.     Name.TextColor3 = color
  50.     Name.TextStrokeTransparency = 0.5
  51.     Name.Font = "SourceSans"
  52.     Name.FontSize = "Size18"
  53.     Name.Text = speaker
  54.     Name.Size = UDim2.new(0,Name.TextBounds.X,0,Name.TextBounds.Y)
  55.     Name.ZIndex = 2
  56.     local Message = Instance.new("TextLabel",ChatFrame)
  57.     Message.Name = "Message"
  58.     Message.BackgroundTransparency = 1
  59.     Message.TextColor3 = Color3.new(255,255,255)
  60.     Message.Font = "SourceSansLight"
  61.     Message.FontSize = "Size18"
  62.     Message.TextXAlignment = "Left"
  63.     Message.TextYAlignment = "Top"
  64.     Message.TextWrapped = true
  65.     Message.Text = msg
  66.     Message.Size = UDim2.new(0,350,0,36)
  67.     Message.Position = UDim2.new(0,Name.TextBounds.X+2,0,0)
  68.     Message.ZIndex = 2
  69.     local Shadow = Message:Clone()
  70.     Shadow.Parent = Message
  71.     Shadow.TextColor3 = Color3.new(0,0,0)
  72.     Shadow.Position = UDim2.new(0,-1,0,1)
  73.     Shadow.ZIndex = 1
  74. end
  75.  
  76. game.Players.PlayerAdded:connect(function(plr)
  77.     if Settings.RandomChatColor == true and #Settings.ChatColors > 0 then
  78.         math.randomseed(os.time())
  79.         plrColor = Settings.ChatColors[math.random(1,#Settings.ChatColors)]
  80.     else
  81.         plrColor = Settings.DefaultChatColor
  82.     end
  83.     local chatGUI = Instance.new("ScreenGui",plr:WaitForChild("PlayerGui"))
  84.     chatGUI.Name = "ChatGUI"
  85.     if Settings.WelcomeMessage == true then
  86.         addMessage("["..Settings.ConsoleName.."]","Welcome to "..Settings.GameName.." "..plr.Name.."!",chatGUI,Settings.ConsoleColor)
  87.     end
  88.     if Settings.PlayerJoinMessage == true then
  89.         for i,v in pairs(game.Players:GetChildren()) do
  90.             if v ~= plr then
  91.                 addMessage("["..Settings.ConsoleName.."]",plr.Name.." has joined "..Settings.GameName.."!",v.PlayerGui.ChatGUI,Settings.ConsoleColor)
  92.             end
  93.         end
  94.     end
  95.     plr.Chatted:connect(function(msg)
  96.         for i,v in pairs(game.Players:GetChildren()) do
  97.             addMessage("["..plr.Name.."]",msg,v.PlayerGui.ChatGUI,plrColor)
  98.         end
  99.     end)
  100. end)
  101.  
  102. game.Players.PlayerRemoving:connect(function(plr)
  103.     if Settings.PlayerLeaveMessage == true then
  104.         for i,v in pairs(game.Players:GetChildren()) do
  105.             if v ~= plr then
  106.                 addMessage("["..Settings.ConsoleName.."]",plr.Name.." has left "..Settings.GameName.."!",v.PlayerGui.ChatGUI,Settings.ConsoleColor)
  107.             end
  108.         end
  109.     end
  110. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement