I think for this instance you’d have to define a type if you want it to work with autofill
type object<T> = typeof(setmetatable(entity.new(script.Name), object)) & {
func: T
}
function object.new<T>(func: T): object<T>
local self = {}
self.func = func
return self
end
If you know what type the other parameters will be beforehand, you don’t have to use generics (<T>) and you can set up as many as you want. Also creating a new entity in the type doesn’t actually create a new entity, the Luau interpreter only checks the return type of the entity so it shouldn’t mess with the mem.
type object = typeof(setmetatable(entity.new(script.Name), object)) & {
func: () -> (),
property0: number,
property1: string
}
function object.new(func: () -> ()): object
local self: object = {}
self.func = func
self.property0 = 0
self.property1 = "test"
return self
end