2 Is OOP possible on instances(parts) in Roblox?

for example :

function newTransparency(self, newT) 
self.Transparency = newT
end
Part = workspace.Part
Part:newTransparency(0.5)
1 Like

I don’t think so but I will try to figure this out.

1 Like

Judging by the code provided, this is not possible. You can add functionality but not directly.

2 Likes

can u please give an example it would be very helpfull since i am new to OOP.

Set up the generic object with OOP style:

local object = {}
object.__index = object
function object.new(Part)
    local construct = {}
    construct.Part = Part
    return setmetatable(construct, object)
end
function object:newTransparency(newT)
    self.Part = newT --> setting the parts transparency to [newT]
end
return object
local thing = require() --> path to module
local Part = workspace.Part

local partWithExtraFunctionality = thing.new(Part) --> adding indirect functionality
partWithExtraFunctionality:newTransparency(0.5) --> calling the added functionality
1 Like