Is it possible to make chat log only for specific channel? So like chat log only for team channel or something like that? So like if admin want to see chat log of Team A they only see chat log of Team A, they don’t need to see all chat logs
Once a player sends a message and they are in the certain team, you can save their message in a table.
Maybe…
1 Like
Do this. There’s a server side PlayerChatted event that would allow you to do this. Connect this event to a player anytime a player joins the game and you’ll be set.
Yes but can I set only to specific team? Or I can make like if player is in team A , it will print the chatlog to GUI 1, if player is in team B it will print the chatlog to GUI 2?
1 Like
I once created this, idk if it still work.
Normal Script in ServerScriptService :
-- MessageCreator
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
local folder = Instance.new("Folder")
folder.Parent = game.ReplicatedStorage
folder.Name = Player.Name
Player.Chatted:Connect(function(Message)
local stringValue = Instance.new("StringValue")
stringValue.Parent = folder
stringValue.Name = ("Message from " .. Player.Name)
stringValue.Value = Message
end)
end)
-- MessageChecker
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
local folder = game.ReplicatedStorage:FindFirstChild(Player.Name)
local messageTable = {}
Player.Chatted:Connect(function(Message)
if Message:lower() == ("/checkmessage") then
for _,I in ipairs(folder:GetDescendants()) do
if I:IsA("StringValue") and I.Name == ("Message from " .. Player.Name) then
table.insert(messageTable, I.Value)
print(#messageTable, I.Value)
end
end
end
end)
end)
Here is some pseudo code that might help.
-- Setup a dictionary for each team
-- Each team can have its own table inside the dictionary. (I assume you can have tables as dictionary values, but I didn’t check. If you can’t, just make it a large table or hardcode a table for each team.)
chat_logs_dictionary = {}
-- This chatted event triggers anytime a player chats
game.Players.PlayerChatted:Connect(function(PlayerChatType, sender, message, recipient)
-- Find the sender’s team color
-- Use the color value, or find the team name and use the team name…
-- Append a table to the table already in the dictionary, which would take the form of {sender, message}
-- After adding the message, check how many messages that team has. If over a certain value, delete the oldest message in that team’s table to prevent a memory leak.
end)
Hope this helps!
1 Like