Trouble with metatable

Heyo, I’ve recently tried to start making an interaction system that references a function based off of a models name but I ran into a problem. I am not 100% knowledgeable in most metamethods so I am trying to learn as I go but how would I go about calling a function based off the string name. I know that it is sending the “Object” as a parameter for the metatable but I’m not sure how else I will call apon it for a function. If you know anything about this, a helping hand would be very much appreciated. Thank you!

,

As you can see, calling the straight function like “InteractClass:ATM(Object)” works in my favor. Otherwise it sets the actual parameter to Object and screws everything up.

That won’t really help since : passes self implicitly.

Just thought I’d mention that InteractClass:ATM(object) is the same as InteractClass.ATM(self, object), it does not matter which you use but they can be used interchangably. self, however, should not be passed with :ATM

Anyways, you were on the right track… rather than passing self there, it should be passed in the initial call of InteractCheck… as in:

InteractClass[name](InteractClass, Object)

It’s a bit confusing since OP named an object the same thing as its class, but it should work nonetheless. (This assumes name is a function in the InteractClass Class)

1 Like

Are you trying to get it so you can
Interact(obj) where ever and it do what ever needs to be done with that kind of object. With the design scheme that, each object will be defined in kind by it’s name?