How do I made module that can be called like this Part:GetName()

Hello Developers,

I am not really sure how this is called but what I am trying to do is to make module that can be called like this workspace.Part:MyModuleFunction() how I could achieve this? Because I can’t find anything about this, and of course how to get that value workspace.Part. That’s all. I am asking, because I don’t deal with modules most of the time and I have no idea on how to that. I know plenty of things like RequiredModule.MyModuleFunction(workspace.Part) but not workspace.Part:MyModuleFunction().

1 Like

You can’t do things like that, you can only do:

RequiredModule.MyModuleFunction(workspace.Part)

There is no way to do that.

1 Like

Then how Datastore2 module allows you to do this: coinStore:Increment(-productPrice)?

it infact is possible, you have to metatable wrap it to make your custom functions so you can call it. here’s how I did mine

I put it in a pastebin because i’m not sure how to format it on devforum. Basically; this script allows you to create custom functions with userdatas.

2 Likes

Because coinStore is a table with a metatable wrapped at it so you can call custom functions. However, you can’t do this on parts