How Can I make My Chatted Event Run If the Player doesn’t Write the message Exactly As Shown in the script?
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if msg == "Bob Is Cool" or msg == "Bob Is Epic" or msg == "Bob Is My Friend" then -- Fixed this line to check msg against both strings
wait(2)
game:GetService("Chat"):Chat(game.Workspace.Bob.Head, "Thanks :)")
end
end)
end)
Ah ok, so the issue that you have is that due to you comparing the message exactly for the string in the if statement it does not check to see if the message is capitalized or not.
To fix this issue, what you could do is make it so the strings in the if statement are not capitalized and then use the method :lower() on the string you get when the user sends a message.
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
local MsgLower = msg:lower()
if MsgLower == "bob is cool" or MsgLower == "bob is epic" or MsgLower == "bob is my friend" then -- Fixed this line to check msg against both strings
wait(2)
game:GetService("Chat"):Chat(game.Workspace.Bob.Head, "Thanks :)")
end
end)
end)
Or what I personally recommend to make your code a bit neater and lets you easily add more messages in the future: