This bug started happening in my game yesterday after a roblox update. Here is the code and place to reproduce the error. It happened with objects in StarterGui that get added to PlayerGui. Adding a wait() right before you do anything with the child fixes the error, so my guess is that InstanceAddedSignal is being called before the object finishes loading to PlayerGui.
local CollectionService = game:GetService("CollectionService")
local function Check(child, where)
local s, e = pcall(function()
return child.Parent
end)
print(where..":", child.Name, "-", s)
error(e)
end
for _, child in ipairs(CollectionService:GetTagged("Button"))do
Check(child, "Get")
end
CollectionService:GetInstanceAddedSignal("Button"):Connect(function(child)
--wait()
Check(child, "Add")
end)
--OUTPUT
-- Add: TextButton - false
--OUTPUT with wait()
-- Add: TextButton - true
CollectionServiceBug.rbxl (15.7 KB)