I encountered a bug where apparently Roblox changes the player backpack instance. My localscript is set up to immediately create a backpack.ChildAdded event listener, which is problematic for me because it ends up setting up the event on the initial backpack instance, but then the backpack instance is switched, rendering the old one obsolete and unused. This means that my event listener is obsolete as well, and ChildAdded will never receive a signal when a new tool is added to the backpack. To give a demonstration, see the following code:
local function ListenForNewTool()
local backpack = Players.LocalPlayer:WaitForChild("Backpack")
local potential_tool = backpack:FindFirstChild("Eyecatcher")
if potential_tool then
UpdateTool(potential_tool)
end
while true do
RunService.Heartbeat:Wait()
print(Players.LocalPlayer:FindFirstChild("Backpack") == backpack)
end
backpack.ChildAdded:Connect(function(child)
print("f")
UpdateTool(child)
end)
while not is_tool_initialized do
ToolInitialized.Event:Wait()
end
end
The script captures the initial backpack instance, and then repeatedly compares it to the current version of the backpack instance in a while true do loop. In the attached image, notice how after a few frames, the script acknowledges that the backpack instance has changed. Has anyone encountered this bug before, and if so, is there a workaround or solution to this?