API:Class/Instance/AncestryChanged

AncestryChanged

Event of Object Icon.pngInstance
RBXScriptSignal AncestryChanged (
    Instance child,
    Instance parent
)
Parameters:
  1. child
  2. parent

Description: Fires when the Parent property of the object or one of its ancestors is changed.

Example

The below example would print "Part is now a child of Model".

local p = Instance.new("Part")
p.Parent = game.Workspace
p.AncestryChanged:connect(function(child, parent)
    print(child.Name.." is now a child of "..parent.Name)
end)
p.Parent = Workspace.Model