title: How to write a Roblox script to save a players backpack and starter gear when they die?
body: <p>I have written a few different scripts and I can't seem to get it right.
  Basically I have a store where players can buy tools and items from, but every time I test it and buy a tool, after I die the tool is gone. I don't want people to have to buy over and over again.</p>
  
  <p>Here is the script for them buying the tool and where the tool will go.</p>
  
  <pre><code>script.Parent.MouseButton1Click:connect(function()
  local RS = game:GetService('ReplicatedStorage')
  local item = RS:WaitForChild('GravityCoil')
  local price = 0
  local player = game.Players.LocalPlayer
  local stats = player:WaitForChild('leaderstats')
  
  if stats.Cash.Value &gt;= price then
      stats.Cash.Value = stats.Cash.Value - price
      local cloned = item:Clone()
      local cloned2 = item:Clone()
      cloned2.Parent = player.Backpack
  end
  end)
  </code></pre>