i made a model with a module script in it it says the following:
return function() script.MyScript.Parent=game:GetService("ServerScriptService") script:Destroy() end
and i put the into the module script and i create a model but im having a difficultyto run the script like i put a script in ServerScriptService but i don't know how to make it so it will put MyScript into the ServerScriptService
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) --// Just change the "script.ModuleScript" to the location of your module script
And then to run the code inside of the module you would do this:
game.Players.PlayerAdded:Connect(function(player) module:WhatEverYouWant(player) --// Or module.WhatEverYouWant(player) end game.Players.PlayerRemoving:Connect(function(player) module:WhatEverYouWantAlso(player) --// Or 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