Question about oop

I’m trying to use object oriented programming for my game, but I ran into an issue.

local module1 = {}
local module2 = require(game.ServerScriptService.module2)

Module1.Health = 50 -- example
Module1.Money = 100

function module1:AddTimeBomb(time)
    module2:CreateTimeBomb(time)
end

return module1 

--module 2

local module2 = {}
module2.__index = module2

module2:BlowUp()
    ---how would I make it do damage to the place it was called?
end


module2:CreateTimeBomb(time)
    local bomb = {}
    setmetatable(bomb,module2)
    --id use run service but for the sake of simplicity I'll just
    -- use a wait
    wait(time)
    bomb:BlowUp()
    return bomb
end
return module2

I know my example is a bit lacking, but the question is how would I make the script required change information in the script requiring it?

That not exactly how OOP works.

OOP is the concept of creating objects. Objects can hold functions, values, references etc.

Module scripts is a placeholder for code. Basically its another way to hide your messy code organize your code.

With module scripts you can use a function to do something and return that if that is what you want to do.

Like this
script

local ModuleScript = require(script.ModuleScript)
local Value = 5
local NewValue = ModuleScipt:Double(Value)
print(NewValue) -- Prints 10

modulescript

local ms = {}
function ms:Double(In)
    local Out = In * 2
    return Out
end
return ms
1 Like

I appreciate the input but that’s not exactly what I meant. I guess my problem is just a structural issue.