War

chat remake

War
Mar 16th, 2017
677
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.63 KB | None | 0 0
  1. local storage=game:GetService("ServerStorage")
  2. local sharedstorage=game:GetService("ReplicatedStorage")
  3. local chatevent=sharedstorage:WaitForChild("ChatEvent")
  4.  
  5.  
  6. local systemfontcolor=Color3.new(.83,.83,.83)
  7.  
  8.  
  9. function sendchat(chattype,name,chat,namecolor,textcolor)
  10.     if chattype=="system" or chattype=="outmatch" then
  11.         for _,plr in pairs(game.Players:GetPlayers()) do
  12.             if true then    --some kind of exclusive chat
  13.                 chatevent:FireClient(plr,name,chat,namecolor,textcolor)
  14.             end
  15.         end
  16.     elseif chattype=="inmatch" then
  17.         chatevent:FireAllClients(name,chat,namecolor,textcolor)
  18.     else
  19.         chatevent:FireAllClients(name,chat,namecolor,textcolor)
  20.     end
  21. end
  22.  
  23. function newplayer(plr)
  24.     print("Player added yes",plr)
  25.     sendchat("system",nil,""..plr.Name.."  joined",systemfontcolor,systemfontcolor)
  26.     local lastchattime=tick()
  27.     local lastmsg=""
  28.     plr.Chatted:connect(function(msg)
  29.         local currenttime=tick()
  30.         if plr and msg and msg~="" and string.sub(msg,1,2)~="/w" and string.sub(msg,1,2)~="/e" and(msg~=lastmsg or (currenttime-lastchattime)>3) and (currenttime-lastchattime)>.5 then
  31.             lastchattime=currenttime
  32.             local lastmsg=msg
  33.             if hascharactertag and hascharactertag.Value and plr.Character then
  34.                 sendchat("outmatch",plr.Name..":",msg)
  35.             else
  36.                 sendchat("inmatch",plr.Character.Name..":",msg,Color3.new(.509,.796,1))
  37.             end
  38.         end
  39.     end)
  40. end
  41.  
  42. game.Players.PlayerAdded:connect(newplayer)A
  43. for _,plr in pairs(game.Players:GetPlayers()) do
  44.     newplayer(plr)
  45. end
  46.  
  47. game.Players.PlayerRemoving:connect(function(plr)
  48.     if plr then
  49.         sendchat("system",nil,""..plr.Name.."  left",systemfontcolor,systemfontcolor)
  50.     end
  51. end)
Advertisement
Add Comment
Please, Sign In to add comment