Cannot add certain types of module functions into remotefunctions

I have no idea how to explain this in the best way possible, but I’ll try my best.

Basically, I am creating a personal framework. The problem is, I cannot call certain module functions,
broken:

RemoteFunction.OnServerInvoke = module:tiger()

Working:

RemoteFunction.OnServerInvoke = module.tiger()

I’ve tried a lot of methods to get it working, but I have no idea why it is not working.

My methods

  • call function through (in pairs)
  • call function through a secondary function which returns given function
  • assign a variable to it

if you can please help me on this I’d be extremely thankful!
screenshots

image

image

Assuming you’re using events for your framework this may be able to help you:

1 Like

What is module.tiger? I’m not entirely sure what is broken and what you’re desired outcome is.

With the self:Fire(“SayHello”) call what were you expecting?

module.tiger is an example of the difficulties I have been facing with. I am not able to call, module:tiger, while i am able to call module.tiger.

also, I was expecting the client to return the player, in which the server prints the player’s name (i took it out but that was my original expectation.

Remove the brackets from the module.tiger()

1 Like

I showed it as an example, the screenshot is definitely different.

1 Like

Could you show what tiger’s code is? (granted of course that’s not just pseudocode)

It’s example code. I used this as an example for my issue. the “tiger” code applies to my issue.

image
This should be

function client.Start(self)
print("something")
end

Then you can do

client:Start()

P.S, when you do module:Test() it adds and extra argument, “self”
So, instead of

function module.Test()
print("Test")
end

It would be

function module.Test(self)
print("Test")
end
2 Likes

In addition to the above answer, (should it be actual code of course) would module.tiger() be supposed to return a function? If not, you’d assign OnServerInvoke as just module.tiger, without any parenthesis.

Oh, yeah. I forgot about that. module:tiger without any parenthesis will not work. However, module.tiger will work without parenthesis. But yes, you are right.

an edit to my op (im testing out bindable events)

Just as a heads up, you probably shouldn’t use : to call custom functions from module scripts, and you shouldn’t define them as such, unless you know what you’re doing. It silently adds an extra argument (as stated above lol) and while it may look better, it’s more trouble than it’s worth.

1 Like

When calling a method, object:method() is just another way of writing object.method(object). It has no special behavior other than that and cannot be used to index members. When trying to index a member, you should always use object.name or object["name"].

To fix your code, you should do the following:

RemoteFunction.OnServerInvoke = module.tiger
1 Like

Yeah, I understand that. You are right: It does come with more trouble than worth.

@woot3 oh, okay. Thanks for clarifying. I thought I needed “:” to index a member into a table.

@JaksonNX thanks for clarifying that to me too you really helped me out aswell

ok, so

module.foo(object) == module:foo()

tysm guys for helping me out.

1 Like

You can define functions without it, like this:

local module = {}
function module.foo()

end
1 Like