Help with chat service to recognize when things are said in chat

As said in the title , can someone help me in what should I do?

Just use .Chatted event:

local Players = game:GetService("Players")
local Client = Players.LocalPlayer or Players:GetPropertyChangedSignal("LocalPlayer"):Wait()

Client.Chatted:Connect(function(msg)
	print(Client.Name.." chatted "..msg)
end)

Do I put the script in a local script?

Yes, of course and I would recommend to put it on StarterPlayerScripts. Btw this script just prints the message that the LocalPlayer sends.

local Players = game:GetService("Players")
local Client = Players.LocalPlayer or Players:GetPropertyChangedSignal("LocalPlayer"):Wait()
local module = require(game.ServerStorage.KosAndAosSettings)
local prefix = module.prefix

Client.Chatted:Connect(function(msg)
	if msg == "/kos" then
		print("Hi this worked")
	end
end)

So something like this would work?

Yes, but only if the whole message is “/kos” I would recommend using :match() to create commands.

where would i add the :match() then

local Client = Players.LocalPlayer or Players:GetPropertyChangedSignal("LocalPlayer"):Wait()
local module = require(game.ServerStorage.KosAndAosSettings)
local prefix = module.prefix

Client.Chatted:Connect(function(msg)
	if msg:match("/kos") then
		print("Hi this worked")
	end
end)

I am trying this but this also wont work

This will only work if the player chats /kos at the beginning of the message (:match() would detect if the player chatted /kos at any part of the message):

local Players = game:GetService("Players")
local Client = Players.LocalPlayer or Players:GetPropertyChangedSignal("LocalPlayer"):Wait()
local module = require(game.ServerStorage.KosAndAosSettings)
local prefix = module.prefix

Client.Chatted:Connect(function(msg)
	if msg:sub(1, 4) == "/kos" then
		print(string.sub(msg, 5, #msg))
	end
end)