You could create a new wrapped instance class like this:
local WrappedInstance = {}
WrappedInstance.__index = WrappedInstance
function WrappedInstance.new(instance: Instance)
local self = setmetatable({}, WrappedInstance)
self.Instance = instance
return self
end
function WrappedInstance:DoSomething()
print("Doing something with " .. self.Instance.Name)
end
-- You can add any function you want
return WrappedInstance
And you can use it like this:
local WrappedInstance = require(Path.To.WrappedInstance)
local myWrappedPart = WrappedInstance.new(Instance.new("Part")) -- you can wrap any instance you want
myWrappedPart:DoSomething()
myWrappedPart.Instance:FindFirstChildOfClass("Script") -- can still access instance properties!