Line 18, attempt to compare number and function

I have this simple rank comparing function built into a module, which simply searches through a list of ranks to determine what rank the player needs. I keep getting the error in the title though, and it concerns this function within the module.

function module.ReturnRank(Level)
	for i,v in pairs(module) do
		if v <= Level then
			return i
		end
	end
end

What’s the issue?

Line 27 is this:

		if v <= Level then

Can you post the specific error message and mark which line is “Line 18” (or whichever line the error message says it occurs on?

The error tells everything, you are attempting to compare number and function

Actually, I may not actually need that. I beleive your error is due to the variable you have in the line:

for i,v in pairs(module) do

Since you have module as your table to loop over, it is iterating through every element of module, including the function ReturnRank, which is a function value - hence the error "attempt to compare number and function.

1 Like

whoops, thanks for that, should’ve renamed my variable to something more better