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

The heck is happening with roblox backpack replication?

So i made a server script which clones tools into player's backpack, simple. But there is that problem, i am trying to access those tools i cloned from local script in StarterPlayerScripts, i see them on my client in the backpack in the explorer and on the server too but the script seems to be blind and does not find anything in the backpack, i made while loop which gets amount of children from the backpack, it printed 0 for 12 generations, then, i tried to use WaitForChild for one of the tools, i have successfully created an infinite yield. Could anybody please explain me this? I am completely confused by that.

Codes:

Server script: When player gets added, it adds the tools from server storage

player.CharacterAdded:Connect(function(character)
			
			if character then
				local human = character:FindFirstChild("Humanoid")
				
				Call("LoadPlayerTools", player, tools)
			end
		end)

Local script: It should get the tools from the backpack

if backpack then
		local toolsToConfigure = {}
		
		for _, tool in pairs(backpack:GetChildren()) do
			if tool and tool:IsA("Tool") then
				table.insert(toolsToConfigure, tool)
			end
		end
		
		return toolsToConfigure
	end

Thanks, kirda

2 comments

0

Could you take your time and provide helpful insights in your code so we could answer your question? I really cannot understand what you're saying.

0

Yea sure i'll do it

2 answers

✓ Accepted answer

Since you only provided fraction of scripts, I cannot be sure that is your problem. If you can show how you reference backpack, I could be more certain.

Backpack behaviour is weird, I think because of the compatibility with old games. It resets with the character. So you need to make sure you are referencing the current Backpack. If your local script resets with character (its in StarterCharacterScripts or in StarterGui), use WaitForChild("Backpack")

However, if your local script does not reset with character (its in StarterPlayerScripts or your Gui is set not to reset on spawn) then you need to connect to CharacterAdded Event:

game.Players.LocalPlayer.CharacterAdded:Connect(function()
	backPack = game.Players.LocalPlayer:WaitForChild("Backpack")	
end)

That being said, if your goal is to add items on spawn only, you may put them in StarterPack instead.

When you equip a tool, it moves the tool into your character model in the workspace, and when you unequip it, it goes back into your backpack. So when you equip your tool, it goes out of your backpack and comes back when you unequip it.

Hope this helps!

2 comments

0

Thanks but that is not the reason, i see the tools in my backpack in the explorer, i don't even equip them

0

well then i have no idea sorry

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