title: Attempt to index nil
body: <p>I am trying to create a pickup, but an error pops up when you pick it up.
  Here is the error:</p>
  <pre><code>Workspace.LogPickup.LogPickupScript:8: attempt to index nil with 'Parent'
  </code></pre>
  <p>Line 8 for the script is the variable player.</p>
  <p>Here is the code:</p>
  <pre><code>local log = script.Parent
  local logGuard = false
  
  local function onTouch(partTouched)
      
      local character = partTouched.Parent
      local humanoid = character:FindFirstChildWhichIsA(&quot;Humanoid&quot;)
      local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
      local playerStats = player:FindFirstChild(&quot;leaderstats&quot;)
      local playerLogCount = playerStats:FindFirstChild(&quot;Has Log&quot;)
      
      if humanoid and logGuard == false then
          
          log.Transparency = 1
          log.CanCollide = false
          logGuard = true
          playerLogCount.Value = 1
          
          wait(5)
          
          log.Transparency = 0
          log.CanCollide = true
          logGuard = false
          
      end
      
  end
  
  log.Touched:Connect(onTouch)
  </code></pre>