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