How do I detect when a player says a letter no matter if its capital or not? I have a randomizing script that puts a StringValue with a Value of a Random Letter inside a player. (its like "C" or "K") I need a script that detects when a player says this letter in any word or sentence [No matter if the letter is capital or not!]
✓ ANSWER ACCEPTED
Detect when player says a letter (but)?
1 answer
✓ Accepted answer
Use Player.Chatted event. Use string.find() to detect if a string contains a specific letter/word.
game.Players.PlayerAdded:Connect(function(player) -- when a player joins
player.Chatted:Connect(function(message, recipient) -- when a player chats
if string.find(message:lower(), "foo") then -- checks if the message contains the word "foo"
print("The message contains the word foo!") -- prints if the message actually contains the word "foo"
end
end)
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
It doesnt work, when i type a letter it doesnt print out anything
instead of "text" i use a value so its just --> letter not "letter"