Problem with AncestoryChanged event

I have a group object that is stored in ReplicatedStorage, I’d like the events to happen when the AncestoryChanged event is triggered. I’d like the event to trigger when the grouped object has been parented to the workspace, I have my code here and it won’t run, the object is parented to the workspace but the code isn’t running and it is very confusing. Here are my 2 attempt codes that yielded no result.

Attempt 1:

local main = script.Parent

main.AncestryChanged:Connect(function(child: Instance, parent: Instance) 
	if parent == game.Workspace then
		print("Hello world")
	end
end)

Attempt 2:

local main = script.Parent

main.AncestryChanged:Connect(function(child: Instance, parent: Instance) 
	if child == main then
		print("Checkpoint 1 Conf")
		if parent == game.Workspace then
			print("Checkpoint 2 Conf")
		end
	end
end)

Both results, the code in the event has never triggered.

If your script is in ReplicatedStorage it wont run. Instead put it in ServerScriptService or either of the starter scripts folders.

Grazi! I’ve now just realized, I’m making a clone of the group and moving THAT into workspace which explains why the method you’ve mentioned doesn’t work in my situation. I appreciate your swift response.

Instead I’m going to just copy the group and instead: move the original group.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.