Instance.AncestryChanged:Connect(function(child, parent)
-- child is the Instance
-- do
end)
Or if you want to run the script when the Instance’s parent changes.
Instance.AncestryChanged:Wait()
-- waits for the Instance's parent to change
-- when it does, this part below will begin executing
Although there isn’t an example, it looks like you understood it properly provided the code snippet? There’s also another example above in the docs which is basically the same thing.