Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Detect when player says a letter (but)?

Asked by 2 years ago
Edited 2 years ago

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!]

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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)
0
It doesnt work, when i type a letter it doesnt print out anything sixfirez 33 — 2y
0
instead of "text" i use a value so its just --> letter not "letter" sixfirez 33 — 2y
Ad

Answer this question