✓ Accepted answer
In the Module Script:
local module = {}
function module.WhatEverYouWant(Arguments)
print("Hello World")
end
function module.WhatEverYouWantAlso(Args)
print(Args.Name.." Has Left The Game")
end
return module
Or You Can Do This As Well
local module = {}
function module:WhatEverYouWant(Args)
print(Args.Name.." Has Joined The Game")
end
function module:WhatEverYouWantAlso(Args)
print(Args.Name.." Has Left The Game")
end
return module
The only difference is on the module function where I changed the period ( . ) to a colon ( : ), it doesn't really matter which on you use.
But to require it, I'd recommend putting it in ReplicatedStorage if you are using a local script or ServerScriptService inside of the script that you are using.
But to require the module script you would do this:
local module = require(script.ModuleScript)
And then to run the code inside of the module you would do this:
game.Players.PlayerAdded:Connect(function(player)
module:WhatEverYouWant(player)
end
game.Players.PlayerRemoving:Connect(function(player)
module:WhatEverYouWantAlso(player)
end
Hope this helped!
If you have any questions comment below, or use the Roblox Wiki and/or Youtube videos!
Link To Wiki:
https://developer.roblox.com/en-us/api-reference/class/ModuleScript
2 comments
actually the colon(:) and the period(.) matter when you approach it in OOP manner
I'm just talking about in general scripting wise. It matters which programming type you use, but not many people are familiar with OOP, LP, FP, PP, etc. So I was just trying to keep it simple.