How to use AncestryChanged? (Trying to get script to check when parts Parent changes)

I have no idea how to use AncestryChanged, and Roblox’s own documentation for it has a blank example.

If someone could explain how I could check when a parts Parent has been changed, that would be really helpful.

Value.AncestryChanged:Connect(function( )

2 Likes

Same as all RBXScriptSignals.

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.

6 Likes