I’ve spent about two hours now searching around for a solution to this, but I can’t find a way to do what I want.
Basically, what I’m trying to do is detect any new instances created within studio (Excluding duplicating and pasting)
Is there any possible methods I could use to detect new instances accurately?
Is there anything I’m missing?
This detects whenever a new Instance
is added to the workspace:
workspace.DescendantAdded:Connect(function(descendant: Instance)
print(descendant.Name, descendant:GetFullName())
end)
To be more clear I meant instances created in general, not just getting parented to something.
I’m just not sure if there is a built in method of detecting it.
Unfortunately I don’t think there is a built in method ( that I don’t know of ) to trace when a new Instance
has been created. However if the Instance
is parented anywhere after the creation then this code can detect it:
game.DescendantAdded:Connect(function(descendant: Instance)
print(descendant.Name, descendant:GetFullName())
end)
But again for instances that are instanced and not parented as such:
local part = Instance.new("Part")
Will not get detected by the code above. However if the instance is parented to anything within the game space, then it should work perfectly fine. As such:
local part = Instance.new("Part")
part.Parent = game:GetService("DatastoreService") -- don't know why you'd put it here but you can if you want.
1 Like