i want to wrap a instance (never done this before, alsow new to metatables and oop)
i made 1 script, and 1 modulescript.
– the modulescript to create the plot
PlotService = {}
function PlotService.New() -- spawn a plot
local plot = {}
local model = Instance.new("Model")
local part = Instance.new("Part")
part.Parent=model
wait()
setmetatable(plot,{
__index = model;
__newindex = model;
})
table.insert(Plots,plot)
--plot.Parent = workspace
return plot
end
return PlotService
–the script to create the wrapped parts
plotservice = require(script.Parent)
local set = plotservice.NewSettings()
local plot = plotservice.New(set)
plot.Name = "plot"
plot.Parent = workspace
print(plot.Parent)
print(plot)
this works for about 1 sec after game starts. then both the model and the part gets destroyed, and i have no idea why.