Module Scripts

0

  • code within module scripts can be used by other scripts
  • makes maintaining code easier since changes only need to be made to one module script
ServerStorage/MoneyManager
local MoneyManager = {}

local questReward = 100 -- Usable only in this module script

function MoneyManager.finishQuest(player) -- Usable in other scripts
    player.Money = player.Money + questReward
end

MoneyManager.animal = "Dog" -- add new key value

return MoneyManager
ServerScriptService/Script
local moneyManager = require(game.ServerStorage.MoneyManager)

print(moneyManager.animal)

moneyManager.finishQuest(player)

https://www.youtube.com/watch?v=qCHTMIDVzVk

https://education.roblox.com/en-us/resources/intro-to-module-scripts

https://developer.roblox.com/en-us/api-reference/class/ModuleScript

  • 0 posts
  • 0 subtopics
  • 3 months ago by vince