Requiring module function without calling

I am following this to make a bindable event, the issue is on the other script (not the module) where you require the function so that you may reference its event, when you require it, it calls the function. What if I do not want it to call the function when I require it?

I tried instead of doing local mouse = require(mousemodule).new(), i tried putting the .new() inside the require, but that worked the same way.

Any ideas?

2 Likes

Don’t write the .new() in the require. Write require(mousemodule) and then when you want to call it do mouse.new()

1 Like

So like

local MouseModule = require(MouseModule)
MouseModule.new().Event:Connect(function()

1 Like

I’m not sure as I’ve never made bindable events in modules, but that does look correct to me.

1 Like

image

If i use that method it wont work anymore, so yeah (when i use other method event works)

1 Like

What is the script that’s erroring? What is line 27?
You definitely require the module instance itself and then call the function. I can’t really figure out what the module itself is doing and I definitely don’t know what “StartRace” is.

1 Like

StartRace is the event, line 27 is the one where i connect to the event, I also also required the module.

Before, at line 1 is the require module, then line 27 is this

MouseModule.Teleport.RaceStarted:Connect(function()

Ok… I don’t know what Teleport is or why it would be inside of MouseModule. What is it you’re trying to accomplish?

1 Like

Teleport is a function in the module, RaceStarted is a event in the function that I am trying to connect to. The problem is i do not know how to require the function without calling it.

You don’t require the function, you require the module and run the function from that. I’m not sure about how to solve this issue, but maybe have the function in the module return the actual event it creates to use that?