Trying to check if a specific message is chatted

I’m fairly new to using the chat service. I’m trying to check if a player types out a specific message, and if they do to make a GUI appear. I’m not quite sure what I’m doing wrong.

local Players = game:GetService("Players")
local Chat = game:GetService("Chat")

Players.PlayerAdded:Connect(function(player)
		Chat.Chatted:Connect(function(character, message)
		if message == ";LaunchGUI" then
			player.PlayerGui:WaitForChild("ScreenGui")
			player.PlayerGui.ScreenGui.Frame.Visible = true
		end
	end)
end)

Am I using the parameters wrong? The script is stored in server script service.

    local Players = game:GetService("Players")
    local Chat = game:GetService("Chat")

    Players.PlayerAdded:Connect(function(player)
    		Player.Chatted:Connect(function(message)
    		if message == ";LaunchGUI" then
    			player.PlayerGui:WaitForChild("ScreenGui")
    			player.PlayerGui.ScreenGui.Frame.Visible = true
    		end
    	end)
    end)

Corrected code. You don’t use the chat service to check if a Player is chatted. This is a PlayerObject based event.

1 Like

The parameters for Chatted are the message and the recipient for if it is a private message.

1 Like

Does this only show up on the player who chatted the word or the whole server, if its only the player how can I make the whole server see the gui when I type a specific message