Module Script -- Game.ServerScriptService.Modules.MonsterDrop
local module = {}
function module:onEnemyDead(enemy)
local tag = enemy:FindFirstChild("Attacker")
if tag ~= nil then
if tag.Value ~= nil then
local leaderStatsMoney = tag.Value:FindFirstChild("Money")
local leaderStatsExp = tag.Value:FindFirstChild("Money")
if leaderStatsMoney ~= nil then
leaderStatsMoney.Value = leaderStatsMoney.Value + (math.random(1,5)*game.Workspace.EventBoost.Value)
wait(0.1)
script:Destroy()
end
if leaderStatsExp ~= nil then
leaderStatsExp.Value = leaderStatsExp.Value + (math.random(10,15)*game.Workspace.EventBoost.Value)
wait(0.1)
script:Destroy()
end
end
end
print(enemy)
end
return module
Server Script -- Workspace.FindFirstChild("Bandit.Exp/Gold Script")
local enemy = script.Parent.Monster
local DropModule = require(game.ServerScriptService.Modules.MonsterDrop)
function Die()
DropModule.onEnemyDead(enemy)
end
enemy.Died:Connect(Die)
Errors: ServerScriptService.Modules.MonsterDrop:3: attempt to index local 'enemy' (a nil value)
Questions: -How would I pass monster parameters and what is a good way of doing it -How would I use collection service in an rpg game that I'm trying to make (Optimized and clean) -How does object oriented work in module scripts, and where are good places to put the module scripts? -Is there any complete guide to using module script? I tried finding on google but I can't seem to find a complete guide

5 comments
Line 5, use a colon : and not a period .
Oooh sorry clumsy mistake xD
Where would I find a complete tutorial for module scripts and object oriented and how could I efficiently apply it to my RPG game? :O
https://www.lua.org/pil/16.html here's a dandy resource
Don't get confuse with parameters & argument, parameters are technically variables, while arguments are the value, so In reality you're passing an argument, The parameter sets the argument as its value.