Type checking not working?

The following function prints Hello rather than the warn when I pass it with a string, any reason why?

function remote:registerCallback(callbackFunction)
	print(type(callbackFunction))
	if not type(callbackFunction) == "function" then
		warn("[REMOTE MANAGER] Given callbackFunction is not a function")
		return
	else
		print("Hello")
	end
	print(type(callbackFunction))
	
	if not table.find(self.callbacks, callbackFunction) then
		table.insert(self.callbacks, #self.callbacks + 1, callbackFunction)
	end
end

Try doing:

if not (type(callbackFunction) == "function") then

or simply:

if type(callbackFunction) ~= "function" then

You are directing the not towards type(callbackFunction), and so if anything is returned from the type checking, not will make it false. Because of this, you would want to structure your if statement in one of two ways mentioned above. The brackets just makes sure that not becomes associated with the equality comparison.

Thank you, it now prints correctly.