Player.Backpack is replaced on Player Join causing some issues with Players.PlayerAdded etc

Bug
If you try getting the Player’s Backpack as soon as the player joins (example: Players.PlayerAdded) and you try to parent anything like a tool. The tool will be parented to some sort of ghost backpack and will vanish. This only happens when a player joins.

game.Players.PlayerAdded:Connect(function(Player)
	local Tool = Instance.new("Tool")
	Tool.Parent = Player.Backpack --Gets parented to some sort of ghost backpack
end)

Repro File:
GhostBackpack.rbxl (29.4 KB)
Change the UseBackpackWorkaround in the script located in ServerScriptService to switch from Player.Backpack to the custom function and view the Backpack in Explorer.

Workaround
Use a wait of a second to prevent this or make a custom function to see if an Instance from StarterPack exists in the backpack.

local function GetActualBackpack(Player, BreakPeriod)
	
	if BreakPeriod == nil then
		BreakPeriod = 300
	end
	
	local BreakTime = os.clock()+BreakPeriod
	
	while true do
		
		local Backpack = Player:WaitForChild("Backpack", BreakPeriod)
		
		if not Backpack then return end --Player left the game
		
		local FixMysteriousBackpack = Backpack:FindFirstChild("FixMysteriousBackpack") --References BoolValue in StarterPack
		
		if FixMysteriousBackpack then --If this variable exists then we know we got the correct backpack and not the buggy one!
			FixMysteriousBackpack:Destroy() --No longer needed
			return Backpack
		end
		
		if os.clock() >= BreakTime then
			return --Out of time!
		end
		
		RunService.Heartbeat:Wait()
		
	end
	
end

Workaround off (FixMysteriousBackpack is from StarterPack). Tool is nowhere.
image

Workaround on, Tool is in the Backpack.
image

1 Like

Thanks for the report! We’ve filed a ticket to our internal database and we’ll follow up when we have an update for you.

2 Likes

Whenever a character is added, a new Backpack is created, and this is intentional. I think this should be seen as an inadvertent feature request to change this behavior, because it’s very unexpected.

1 Like

Please also see this older thread:

2 Likes

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