Chatlogs script is not working

I am not using this for any practical purposes or anything, this is just a test, just wanted to make this clear.

So, what I am making is that I am making sort of a command where if a user says “/chatlogs”, a GUI appears showing them the chatlogs.
This requires 3 scripts, the one for the /chatlogs command, the one that logs the chats and puts them in the GUI, and the one for the close button.
Script 3 does work, however it’s not the same with scripts 1 or 2.
Honestly I don’t even know what i’m doing wrong here, no errors in the output or anything, just that it doesn’t seem to work.
All scripts are LocalScripts, and I tried this with regular Scripts as well and it still doesn’t work. Here are the scripts:

Script 1:

chatlogs = script.Parent.chatlogs
local function onMessageReceived(player, message)
	if message == "/chatlogs" or message == "/Chatlogs" or message == "/ChatLogs" or message == "/CHATLOGS" then
		chatlogs.Visible = true
		game.Lighting.Blur.Enabled = true
	end
end
game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		onMessageReceived(player, message)
	end)
end)

Script 2:

function getTime()
	local year = os.date("%y")
	local month = os.date("%m")
	local day = os.date("%d")
	local hour = os.date("%I")
	local minute = os.date("%M")
	local second = os.date("%S")
	local amorpm = os.date("%p")
	return day.. "/" ..month.. "/" ..year.. ", " ..hour.. ":" ..minute.. ":" ..second.. " " ..amorpm
end
main = script.Parent
main.TextLabel.Text = ""
local function onMessageReceived(player, message)
		main.TextLabel.Text = "[" .. getTime() .. "] "  .. player.Name .. " says: \"" .. message .. "\"" .. "\n" .. main.TextLabel.Text
end
game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		onMessageReceived(player, message)
	end)
end)

Script 3 (this one does work):

close = script.Parent
chatlogs = script.Parent.Parent.Parent
close.MouseButton1Click:Connect(function()
	chatlogs.Visible = false
	game.Lighting.Blur.Enabled = false
end)

I tried putting the scripts into Assistant, but then it just gave me the most unhelpful response ever (bruh). Then I tried searching the output tab to see if there was any errors, no errors, so apparently this works without any errors, but when i use this, it just doesn’t work.

Screenshots:

Explorer:

image

Player.Chatted only fires on the server, so running this on a local script wouldn’t work because callbacks are never invoked. It is also important to note that Player.Chatted returns the unfiltered text and adding gui’s with unfiltered text could result in your game being taken down.

To solve it you can use TextChatService

game.TextChatService.MessageReceived:Connect(function(msg)
    print(msg.Text)
end)

however I don’t think it fires on localscripts when players use built in / commands (such as whisper or /e dance)

I’ll try that and see what happens

Still does not work

If you’re running it from a local script try it on a server script and if that does not work then I don’t know what the issue is

Ok then

charrrrrrrrrrrrrrrrrrrrrrrrrrrrrsssssssssss

I’ll just give up and return to the problem in like 3 months when i have a bit more experience in scripting, cuz this does work with a physical wall

1 Like