Checking if a function/method should be called with a dot or a colon

I need to help to create a piece of code that programmatically checks if something is a method or a function

So im creating a Visual scripting Plugin for Roblox Studio, which is really cool and should make coding more accessible for younger people.
So far ive gotten a big object tree with classes, enums, globals, librarys, etc. But the main issue im running into is that for stuff like Part:Destroy() or Part:Clone() my program would need to know if something is a method (which i guess need a colon) or a function (which i guess need a dot).

My solution would be to use PCall to execute a function which tests the validity of the method/function. So it tries : or . If one fails we know it must be the other.
But that is more simply said then done. For stuff like instances I cant do “Instance:Clone”, i have to get something that inherits Instance and then execute that Pcall. Trace this information back to the “Superclass” and apply it to that. From then on we know that it’s either a method or a function.

This… doesnt seem very efficient, i could make a program that does this once, saves it to JSON then gives it to me, but this would warrant regular maintaining, because im relying on a different APIdump for most of this data.

I was wondering what your guy’s take on this would be. Maybe you got something more efficient! Lets brainstorm about this together!

So Im just asking for ideas here not complete pieces of code, though that would be nice, im just asking for suggestions.

Ive basically already got a system, but it may not be a very efficient one…

Thanks guys in advance you are the best

Afaik there are no Instances or datatypes that use functions over methods. The only time functions are used are for libraries so, you should expect the user to call all functions of Instances/datatypes as methods.


@Kabutey is right. Also, check out @Maximum_ADHD’s API Dump Tool. It might be useful for this problem and also for other areas of your project.

1 Like

Oh um what i actually mean is that is stuff like Part:Clone() i know that i need to call it with a Colon but the plugin doesn’t know that (yet).

What you said made me think… yea there probably no instances where a colon is not used!

Stuff like game:getservice(), part:clone() or model:getchildren all have a colon!

It was quite late in the evening when I posted this so i might have not thought of it that well :stuck_out_tongue_winking_eye:

Anyways indeed only library items seem to be called with a . Like math.sqrt()!

Thanks for you help!

1 Like

Ooh yes that tool does seem very handy,
although from what I see it is not in a JSON format (if the output is like the example he showcased), which I currently use to generate the tree.

It will probably proof useful in the long run! As a bonus it seems like the format would be reasonably easy to put into the tree.

I will look further into this, because it would seem that this is better then the current API dump i am using!

Thanks for the recommendation!

I just noticed that he already has a APIDump.JSON so i could easily use that!

1 Like

The whole purpose of using : in a call is to effectively substitute Table:Function(a, b, c) with Table.Function(self, a, b, c) where self is the table on the left-hand side of the : operator.

In the case of Roblox instances, any function call in the context of an instance will always use : instead of .

The one time this isn’t the case is when you’re defining a Callback, such as BindableFunction.OnInvoke or MarketplaceService.ProcessReceipt.

Both of these example cases are explicitly defined as Callbacks in the JSON API Dump, where-as everything else is defined as a Function.