Instance wrapping deletes instance

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.

Maybe anchoring model or part would help you ? I guess the problem is because when they spawn they fall down into the void and because of this they disappear ?

edit: you can just anchor the model I believe.

I was really overcomplicating things… I`m gone rethink life for a minute of 2 and then continue with my project. thank you.

1 Like

No worries, same happens to me :wink:
Have a good time doing you project!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.