When chatting, go thru a list of potential messages isnt working

basically im trying to when you chat it will go thru a list of messages or strings, and if one of the messages are the same as one of the messages in the table then it’ll give an output, which will be print("yes")
i was messing around pretty much, but when it does work it works for all messages and when it doesnt it doesnt work for any message

local t = {"hey","hi","hello"}

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if msg:split() then
			print("yes")
		end
	end)
end)

NOTE: i went thru a lot of ways to do this but i couldnt find any that would let any message make an output or just break

1 Like

Something like this?

local t = {"hey","hi","hello"}

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if table.find(t, msg) then
			print("yes")
		end
	end)
end)
1 Like

omg i was messing with the table library aswell, why didnt i think of this