Help with module scripts

I’m doing some practice with module scripts. I’d like help on how Events would work in a module and when they would run. For example:

local Module = {}

function Module.Testfunc()
    print("Hello World!")
end

Runservice.Heartbeat:Connect(function()
    print("Bye World!")
end)

return Module

Im wondering when the runservice event would run. Would it run after the function above has been called, when the module is required etc.

The code is run when the module script is required.
You are only defining the Testfunc function, not running it, so it doesn’t yield the script.

ModuleScript runs if it’s required by either a server or client and function has been used, right now you have a function that can be called and RunService event which i assume runs soon as it’s been required. (i mostly put event in function but not outside if it’s in ModuleScript)

and since function hasn’t been called, Only run service gets executed to the script so it just prints Bye World but not the function we created.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.