War icon

chat remake

War | PRO | 03/16/17 10:09:45 PM UTC | 0 ⭐ | 735 👁️ | Never ⏰ | []
Lua |

1.63 KB

|

None

|

0 👍

/

0 👎

local storage=game:GetService("ServerStorage")
local sharedstorage=game:GetService("ReplicatedStorage")
local chatevent=sharedstorage:WaitForChild("ChatEvent")
 
 
local systemfontcolor=Color3.new(.83,.83,.83)
 
 
function sendchat(chattype,name,chat,namecolor,textcolor)
    if chattype=="system" or chattype=="outmatch" then
        for _,plr in pairs(game.Players:GetPlayers()) do
            if true then    --some kind of exclusive chat
                chatevent:FireClient(plr,name,chat,namecolor,textcolor)
            end
        end
    elseif chattype=="inmatch" then
        chatevent:FireAllClients(name,chat,namecolor,textcolor)
    else
        chatevent:FireAllClients(name,chat,namecolor,textcolor)
    end
end
 
function newplayer(plr)
    print("Player added yes",plr)
    sendchat("system",nil,""..plr.Name.."  joined",systemfontcolor,systemfontcolor)
    local lastchattime=tick()
    local lastmsg=""
    plr.Chatted:connect(function(msg)
        local currenttime=tick()
        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
            lastchattime=currenttime
            local lastmsg=msg
            if hascharactertag and hascharactertag.Value and plr.Character then
                sendchat("outmatch",plr.Name..":",msg)
            else
                sendchat("inmatch",plr.Character.Name..":",msg,Color3.new(.509,.796,1))
            end
        end
    end)
end
 
game.Players.PlayerAdded:connect(newplayer)A
for _,plr in pairs(game.Players:GetPlayers()) do
    newplayer(plr)
end
 
game.Players.PlayerRemoving:connect(function(plr)
    if plr then
        sendchat("system",nil,""..plr.Name.."  left",systemfontcolor,systemfontcolor)
    end
end)

Comments