Roblox Chat Logs For Specific Users

I own a Sword Fight game and I was looking to keep a eye on my mods is there a way to only keep chat logs of a specific users? Here the script I had.

game.Players.PlayerAdded:connect(function(Player)
Player.Chatted:connect(function(Message)
local Data = {
[‘username’] = Player.Name,
[“content”] = "Player: “…Player.Name…” “…”\nMessage: “…Message…” “…”\nChat Id: "…math.random
}
local NewData = HttpService:JSONEncode(Data)
HttpService:PostAsync(Webhook,NewData)
end)
end)

1 Like

Are you using a Discord webhook?
I wouldn’t recommend on using webhooks due to rate limits…

1 Like

you could do
if Player.name = “username” then

1 Like

You can do something like this:

local userids = { -- table to hold the userids
   107157606, -- my user id for example
   1 -- roblox's userid
}

Players.PlayerAdded:Connect(function(player)
    if table.find(userids, player.UserId) then
       -- log their chat
    end
end)

I don’t recommend using their username because if they change it, their chat won’t be logged anymore.

1 Like

i really don’t reccomend sending a webhook everytime a player has chatted. It can overload very quick.

A work-around i can think of is logging all the mesages in one table, and only sending the webhook once.

local Logs = {}

game.Players.PlayerAdded:Connect(function(plr)
    Logs[plr] = {}

    plr.Chatted:Connect(function(message)
        table.insert(Logs[plr], message)
    end)
end)

game.Players.PlayerRemoving:Connect(function(plr)
    local ChatHistory = Logs[plr]

    --put them into one string
    local s = ""
    for _,msg in pairs(ChatHistory) do
        s = s..msg.." \n"
    end

    --//rest of the webhook stuff here, sending string s
end)
4 Likes