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

player inventory disappears when player dies?

I have the save backpack working but I used a tutorial that actually worked perfectly the first try. There's only one small issue, when the player dies, any weapon that was purchased gets destroyed and upon respawn there is an extra starter pistol.

How do I make players keep inventory even when they die?

char.Humanoid.Died:Connect(function()
			char.Humanoid:UnequipTools()
			
			local old = player.StarterGear:GetChildren()
			for i = 1, #old do
				old[i]:Destroy()
			end
			
			local new = player.Backpack:GetChildren()
			for i = 1, #new do
				new[i].Parent = player.StarterGear
			end
		end)

Here is the function I believe is the reason for some weird stuff happening.

Again this tutorial worked, which is great, but now I'm not really sure what I'm looking at. Can anyone explain why this issue is happening? Thanks!

1 answer

            local new = player.Backpack:GetChildren()
	    local newClone = new:Clone(
            for i = 1, #new do
                newClone[i].Parent = player.StarterGear
            end

idk if it would work didnt tested it please dont leave hate comments

1 comment

0

I see what you're going for. I'll try it out. Thanks!

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