How to find string in table non Case sensitive

Unfortunately still same error.

1 Like

May I see your code? I don’t think its anything wrong with what I sent you. At least the line where the error is happening.

1 Like

Yes this is the part of the code

function CodesFunction.OnServerInvoke(Player, Code) 
local CodesFolder = Player:WaitForChild("CodesFolder") 
  for Key, Value in pairs (Codes) do
	if string.lower(Value) == string.lower(Code) and not CodesFolder:FindFirstChild(Code) then 

note: I am planning to do the same thing with this

CodesFolder:FindFirstChild(Code)

Codes - is the table

1 Like

Hmm can you send that entire function please.

1 Like
function CodesFunction.OnServerInvoke(Player, Code) 
	local CodesFolder = Player:WaitForChild("CodesFolder") 
	for Key, Value in pairs (Codes) do
		if string.lower(Value) == string.lower(Code) and not CodesFolder:FindFirstChild(Code) then 
			print("find")
			local CodeTable = Codes[Code] 
			local CodeActive = CodeTable[1] 

			if CodeActive then 
				local BoolValue = Instance.new("BoolValue") 
				BoolValue.Name = Code
				BoolValue.Parent = CodesFolder
				
				print("done")
				return 3
			else
				return 2
			end
		else
			return 1
		end
	end
end
1 Like

And can you tell me the exact line of error also?

1 Like
if string.lower(Value) == string.lower(Code) and not CodesFolder:FindFirstChild(Code) then 
1 Like

Ok so is there a stringvalue in the CodesFolder or something?

edit:
nvm

1 Like

Ok, Instead can you send the entire script? I would also make sure there is nothing else named Value, Code, Key, Codes, or CodesFolder.

edit:
The error does seem to be something to do with a reference error/wrong reference. So double check the names of your values.

2 Likes

Oh I forgot to state that its Module Script Table

local Codes = require(script.Codes)
1 Like

Why? Just have the table in our script. Also if you dont want to change it just show me whats in the module.

1 Like
local Codes = {

["testingcode"] = {true},

}

return Codes
1 Like
local Codes = {

testingcode = true,

}

return Codes
1 Like

It detects as first return.
So “invalid”

What detects as a first return?

if string.lower(Value) == string.lower(Code) and not CodesFolder:FindFirstChild(Code) then

and if this is not passed it returns 1 - Invalid

Ah I see change the string.lower(Value) to string.lower(Key). I would also just recommend having the table in the script.

Still and I will probably need to do it.

Well I dont know how I did not think of this before but are you ever calling for the table/is your module returning it to the script (ik it has return but try putting it in a function like below)? As your just requiring the module.

Script (Codes var):

local Codes = require(script.Codes):Get()

Module:

local module = {}

function module:Get() 
	local Codes = {

		testingcode = true,

	}

	return Codes
end

return module

No it still returns as invalid.