I’m trying to detect what a player says and if they say something specific then it runs that piece of code. I was using this but it runs every time you chat not just when you say “Breath Air”
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if message == "Breath Air" or "BREATH AIR" or "breath air" then
Your understanding of logical operators seems to be a bit flawed.
This expression:
message == "Breath Air" or "BREATH AIR" or "breath air"
is equal to this:
(message == "Breath Air") or ("BREATH AIR") or ("breath air")
In this case, this would evaluate to "BREATH AIR" if the message doesn’t equal to "Breath Air" and this would pass though the conditional because a string is not false or nil.
A better way to do is that you would lowercase all of the characters in the message and check for every possible combination with a single check:
That was for visualisation to show why it doesn’t work. Your old method would only check for "Breath Air" while giving the other two a pass, which in return, would always evaluate to a truthy value.