How do I check if a function exists inside a table?

I looked at this post and I get a warning when I do what they said to do in the answer, it says.

I am wondering if there is a way that I can get rid of this warning?

local exampleTable = {}
if exampleTable.exampleFunction then

Can you post your script so we can better help you?

I will give an example, but this is for purely knowledge not a large scale script

I edited my post, does this clarify my question?

local exampleTable = {}
if typeof(exampleTable.exampleFunction) == "function" then

typeof() will return “nil” if exampleFunction isn’t there or something else if it’s a different data type.

That still gives me the same warning, thanks anyway.

What does the warning say?


To clarify, the above code works, it just displays a warning, and if I have hundreds of those, well those warns would get annoying.

It’s on the top of the post, but here it is anyway

That’s just the syntax highlighter; there shouldn’t be any error/warning at run-time.

But hundreds of those, definitely gets annoying and if I have all types of those things…

You should probably fix them then, just to keep your code clean. If “exampleFunction” is meant to be defined later then you could just put a placeholder value when you define “exampleTable” in order to silence the warning.

The warning is showing because in the script you are indexing a key that isn’t hard-coded in the table; it’s confusing the syntax checker.

Alternatively, to silence this, you can use square brackets and use the matching name in a string into the brackets to find it.