Player.Chatted thing won't work

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I just want it to do something when I you type “Hail Felipe!”
  2. What is the issue? Include screenshots / videos if possible!
    It just doesn’t work at all, I don’t really know how to explain it.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have just tried different formatting and looked around on discord.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local Player = game.Players.LocalPlayer

local Event = game.ReplicatedStorage.RemoteEvent

Player.Chatted:Connect(function(msg)
	if msg == string.lower("Hail Felipe!") then
		Event:FireServer(Player)
		print("First one works...")
	else
		print("Not works")
	end
	end)
1 Like

You are lowering ‘Hail Felipe!’
So it will never work.
Should be like this:
if msg == “Hail Felipe!” then

I will test that, my brain just won’t work right now.

But won’t you have to type the caps and everything exactly correctly then?

if the message is ‘Hail Felip!’ it will run.

Otherwise make this:

local Player = game.Players.LocalPlayer

local Event = game.ReplicatedStorage.RemoteEvent

Player.Chatted:Connect(function(msg)
local msg = "Hail Felipe!"
	if msg:lower():sub(1,#msg) == msg then
		Event:FireServer(Player)
		print("First one works...")
	else
		print("Not works")
	end
	end)

And it still won’t work for some reason.

That SHOULD work if you type “Hail Felipe!”…

or use this if you don’t want it to be exactly ‘Hail Felipe!’

local Player = game.Players.LocalPlayer

local Event = game.ReplicatedStorage.RemoteEvent

Player.Chatted:Connect(function(msg)
local msg = "Hail Felipe!"
	if msg:lower():sub(1,#msg) == msg then
		Event:FireServer(Player)
		print("First one works...")
	else
		print("Not works")
	end
	end)

I will go on another test world. Maybe my studio is broken right now.

Have you tried lowercasing the player’s input? string.lower(msg) == "hail felipe!"
Have you also tried sanitizing the input by doing the following?

msg = msg:gsub("%c", "");

EDIT
Roblox a while back broke the chat, what happens is that when a player hits enter a control character gets added to the input. To sanitize this is to remove this said character. The pattern %c would remove said character with the gsub.

I am confused. What is sanitizing.

Eh, I just took one of my old scripts.