Script only takes 4 values

Hi! So I am making a guess the logo type game and this is what I am using to check the player message:

local thecharacter = script.Parent.TheCharacter
	if (msg == string.lower(thecharacter.Value or script.Parent.TheCharacter2.Value or script.Parent.TheCharacter3.Value or script.Parent.TheCharacter4.Value)) then 

The problem is, the script is only traking theCharacter. Value and TheCharacter2.Value not the third and fourth value. Is the some way to fix this?

Do this

if msg == (string.lower(thecharacter.Value) or string.lower(script.Parent.TheCharacter2.Value) or string.lower(script.Parent.TheCharacter3.Value) or string.lower(script.Parent.TheCharacter4.Value)) then

This, but you guys are both treating it like English, and it’s not English.
This is how it should be formatted.
if msg == string.lower(a) or msg == string.lower(b) or msg == etc

1 Like

There are red lines under each of the letters when I do that.

You can’t compare values like this. Put them into a table and use table.find().

local thecharacter = script.Parent.TheCharacter
	local msgs = {
		string.lower(thecharacter.Value),
		string.lower(script.Parent.TheCharacter2.Value),
		string.lower(script.Parent.TheCharacter3.Value),
		string.lower(script.Parent.TheCharacter4.Value)
	}
	if table.find(msgs, msg.lower()) then
1 Like

I’m on mobile and didn’t want to type out all of the inputs such as the character.Value. it’s the format you need to pay attention to though, don’t copy it directly

Didn’t work. It doesn’t even do the first two values anymore.

Does it have an error? I did edit the script a few seconds after posting it after realizing I messed up on something. If it doesn’t have an error, it has nothing to do with what I provided, but rather what the script is receiving.

There is no error in the output.

Try this

local found = (
	msg == string.lower(thecharacter.Value) or 
	msg == string.lower(script.Parent.TheCharacter2.Value) or
	msg == string.lower(script.Parent.TheCharacter3.Value) or
	msg == string.lower(script.Parent.TheCharacter4.Value)
)
if found == true then
	print("matched!")
end

Try printing msg and check whether it is what you think it is or that it matches.

local thecharacter = script.Parent.TheCharacter
	local msgs = {
		string.lower(thecharacter.Value),
		string.lower(script.Parent.TheCharacter2.Value),
		string.lower(script.Parent.TheCharacter3.Value),
		string.lower(script.Parent.TheCharacter4.Value)
	}
	print(msg, msgs)
	if table.find(msgs, msg.lower()) then

This worked. Thank you so much!

1 Like

Your welcome, what I did here was making the found variable one of these values, if any of them is true it will be true or just false