So I’m making a thing where when you chat a special message, it’ll teleport you, however I’m trying to figure out how I could make it completely ignore caps lock and if the letters are the same as the string applied, it will do it.
You can convert the string to lowercase and then check if that equals something:
function IsCorrect(str)
str = string.lower(str)
if (str == "...") then
-- // Is correct.
end
end
I tried comparing it with string.lower and string.upper, however it would only detect upper like “THIS” and not like “THis”
Can you send the code that handles that?
I removed it out of the script but it was comparing the string.lower and the string.upper of the message the player sent and comparing it to the applied message, which was “Hello!”
Was the text you were comparing it to completely lowercase?
No, however it worked in the forms of “HELLO!” and “hello!”
You have to compare 2 lowercase strings, that should work:
local someString = "HELlO!"
local correctString = "hEllo!"
if string.lower(someString) == string.lower(correctString) then
-- // It is correct
end
In this example no matter how you will write someString
and correctString
, they will be equal as long as they contain the same characters ignoring capital letters.
Thank you! It works now!!!
local correctChat = “tp”
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if msg == correctChat.lower() then
– do something
end
end)
end)