Can a plugin retreive a newly inserted object? [Answered]

I am making a plugin. When the user inserts an object (from AdvancedObjects etc) the plugin will get that object, then the plugin will apply user-determined properties to the newly inserted object.

The problem I have is getting the plugin script to retrieve the newly inserted object.

I’ve searched ScriptingHelpers and the API Reference trying to find a solution but to no avail.

This is the best I could come up with:

connection = selection.SelectionChanged:Connect(function()
	local selected = selection:Get()[1]
	selected.ChildAdded:Connect(function(child)
		applyConfig(child)
		connection:Disconnect()
	end)
end)

This sort of does what I need, however, I need it to work only on newly inserted objects.

Is there a built-in feature for this? or some workaround I haven’t thought of?

Thanks.

There is no API for this. Here’s a feature request for one. The best that you can do right now is what you’re doing + detect if the object has the default studio properties for that object type.

1 Like