Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

player inventory disappears when player dies?

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago
            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

0
I see what you're going for. I'll try it out. Thanks! DaGlizzzzzzyyyy 34 — 3y
Ad

Answer this question