Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a Script which detects when an Ancestry of your choosing has changes to its Hierarchy?

What my codes supposed to do is detect when a change to the Hierarchy is made and print a message afterward.

game.Workspace.debrisTest.AncestryChanged:Connect(function()
	print("something changed!")
end)

I have a Model in the game which has a Part with a Script in it that sets its Parent to Workspace, but nothing happens when it goes to the Workspace. Help?

1 answer

What you are doing is connecting the function to the event after the object has already moved to the workspace. To fix this, reference the object before moving it to the workspace.

For example,

  1. There is a part in ServerStorage

  2. This script executes: game.ServerStorage.Part.AncestryChanged:Connect(function() print("Hey") end)

  3. Now I move the part into workspace

  4. It outputs "Hey"

Your process,

  1. Part gets moved into workspace

  2. You connect event to Part

  3. Since Part is already in Workspace, event does not get called

Specific details on why you need this would be helpful but I am going to assume it is to begin a timer that deletes the debris object after X seconds pass.

1 comment

0

Ooooh, ok. The end goal is that when the welds are removed from a Part a Script will detect that change in Ancestry and begin a countdown to remove the debris, as you said. Would that be a viable method?

This discussion is preserved as it was. New answers, comments, and votes are closed.