function saveWeapons(player) local bin = Instance.new("StarterGear") --Changed HopperBin to StarterGear bin.Parent = game.Lighting bin.Name = player.Name local stuff = player.Backpack:GetChildren() for i = 1,#stuff do local name = stuff[i].Name if game.StarterPack:findFirstChild(name)==nil then stuff[i]:Clone().Parent = bin end end local char = player.Character:GetChildren() for i = 1,#char do if char[i].className == "Tool" then local name = char[i].Name if game.StarterPack:findFirstChild(name)==nil then char[i]:Clone().Parent = bin end end end end function onRespawned(player) local findBin = game.Lighting:findFirstChild(player.Name) if findBin~=nil then local stuff = findBin:GetChildren() for i = 1,#stuff do stuff[i]:Clone().Parent = player.Backpack end findBin:Remove() end player.Character.Humanoid.Died:connect(function() saveWeapons(player) end) end function onPlayerEntered(newPlayer) newPlayer.Changed:connect(function (property) if (property == "Character") then onRespawned(newPlayer) end end) while true do if newPlayer.Character~=nil then break end wait() end newPlayer.Character.Humanoid.Died:connect(function() saveWeapons(newPlayer) end) end game.Players.PlayerAdded:connect(onPlayerEntered)
I get this error.
11:04:59.910 - Workspace.SaveWeapons:32: attempt to index field 'Character' (a nil value) 11:04:59.912 - Stack Begin 11:04:59.913 - Script 'Workspace.SaveWeapons', Line 32 - global onRespawned 11:04:59.914 - Script 'Workspace.SaveWeapons', Line 40 11:04:59.916 - Stack End