How does __namecall work?

I’ve asked a similar question before, __newindex, __namecall, and how to differentiate the two - #3 by HugeCoolboy2007, but I believe I now know how to better ask it.

So, I’m trying to figure out how __namecall works, since its unique to Roblox.
For awhile I thought it to be restricted to Instances, but I’ve learned recently you can actually use them on userdatas.
For whatever reason, __namecall is actually not on the Roblox api reference.

So that brings me to my main question: How to determine the function being fired using __namecall?
I’ve printed the args passed to __namecall, yet it only passes itself and the args passed.
If you can just check if the first argument is itself in a call, why even use __namecall? Why and how does Roblox use it for their own Instances?

Edit: To be clear of my intentions with it for better support on the subject, I am making a Library that allows you to make objects that behave like Instances (of course its not possible to be 100% similar)

2 Likes