When opening the chatlogs, the request_output
function is fired however when looping through the table received from a module script everything seems to be on there twice?
Code:
-- ServerScript
function request_output(net)
local chatHistory = require(game:GetService("ServerScriptService"):WaitForChild("Chat"):WaitForChild("GetChats"))("Chats")
for _, chat in ipairs(chatHistory) do
net:send('Output', 'Message', string.format("[%s]: %s", chat.Player.Name, chat.Message), chat.Date, chat.Timestamp)
end
end
-- ModuleScript
local chatInputted = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents"):WaitForChild("ChatInputted")
local chats = {}
local commands = {}
function getChats(tt)
if tt:lower() == "chats" then
return chats
elseif tt:lower() == "commands" then
return commands
else
return false
end
end
chatInputted.OnServerEvent:Connect(function(placeholder, player, message)
if #chats >= 1000 then
table.remove(chats, #chats)
end
table.insert(chats, 1, { Message = message, Player = player, Timestamp = os.time(), Date = os.date("%x") })
print('chat inputted')
end)
return getChats
I’ve checked the remote event and it is definitely only firing once.