[gmod-industrialization] addons/gmod-industrialization/lua/modules/resource_management.lua:30: attempt to index local 'player' (a nil value)
  1. AddPlayerResource - addons/gmod-industrialization/lua/modules/resource_management.lua:30
   2. unknown - addons/gmod-industrialization/lua/entities/resource_node/init.lua:46 (x9)
```lua
-- lua/modules/resource_management.lua

if SERVER then
    util.AddNetworkString("Industrialization_UpdateInventory")
    util.AddNetworkString("Industrialization_Notify")

    PlayerInventory = PlayerInventory or {}
    AvailableResources = AvailableResources or {
        wood = 500,
        metal = 300,
        oil = 200,
        minerals = 100,
    }

    -- Initialize player inventory on spawn
    hook.Add("PlayerInitialSpawn", "Industrialization_InitInventory", function(player)
        PlayerInventory[player:SteamID()] = {
            wood = 0,
            metal = 0,
            oil = 0,
            minerals = 0,
            refined_metal = 0,
            electronics = 0,
            -- Initialize other resources
        }
    end)

    -- Function to add resources to player inventory
    function AddPlayerResource(player, resource, qty)
        if not PlayerInventory[player:SteamID()] then return false end
        if not ResourceTypes[resource] then return false end

        if (PlayerInventory[player:SteamID()][resource] or 0) + qty <= 1000 then -- Max limit
            PlayerInventory[player:SteamID()][resource] = PlayerInventory[player:SteamID()][resource] + qty
            AvailableResources[resource] = (AvailableResources[resource] or 0) - qty
            -- Notify player
            player:ChatPrint("You have gained " .. qty .. " " .. ResourceTypes[resource].name)
            -- Update UI
            net.Start("Industrialization_UpdateInventory")
                net.WriteTable(PlayerInventory[player:SteamID()])
            net.Send(player)
            return true
        else
            player:ChatPrint("Cannot carry more " .. ResourceTypes[resource].name)
            return false
        end
    end

    -- Function to remove resources from player inventory
    function RemovePlayerResource(player, resource, qty)
        if not PlayerInventory[player:SteamID()] then return false end
        if not ResourceTypes[resource] then return false end

        if PlayerInventory[player:SteamID()][resource] and PlayerInventory[player:SteamID()][resource] >= qty then
            PlayerInventory[player:SteamID()][resource] = PlayerInventory[player:SteamID()][resource] - qty
            AvailableResources[resource] = (AvailableResources[resource] or 0) + qty
            -- Notify player
            player:ChatPrint("You have used " .. qty .. " " .. ResourceTypes[resource].name)
            -- Update UI
            net.Start("Industrialization_UpdateInventory")
                net.WriteTable(PlayerInventory[player:SteamID()])
            net.Send(player)
            return true
        else
            player:ChatPrint("Not enough " .. ResourceTypes[resource].name)
            return false
        end
    end

    -- Function to spawn initial resource nodes
    function SpawnInitialResourceNodes()
        local positions = {
            Vector(100, 100, 10),
            Vector(200, 200, 10),
            Vector(300, 300, 10),
            -- Add more positions as needed
        }

        for _, pos in ipairs(positions) do
            local resourceType = table.Random({"wood", "metal", "oil", "minerals"})
            SpawnResourceNode(resourceType, pos)
        end
    end

    -- Function to spawn a resource node
    function SpawnResourceNode(resourceType, position)
        if not ResourceTypes[resourceType] then return end

        local node = ents.Create("resource_node")
        node:SetModel(ResourceTypes[resourceType].model)
        node:SetPos(position)
        node:SetNWString("ResourceType", resourceType)
        node:SetNWInt("ResourceQuantity", 10) -- Initial quantity
        node:Spawn()
    end

    -- Recycling system
    function RecycleWaste(player, wasteType, qty)
        if ResourceTypes[wasteType] and wasteType == "scrap_metal" then
            if RemovePlayerResource(player, "scrap_metal", qty) then
                AddPlayerResource(player, "refined_metal", qty)
                player:ChatPrint("Recycled " .. qty .. " Scrap Metal into Refined Metal")
            end
        else
            player:ChatPrint("Invalid waste type for recycling.")
        end
    end

    -- Handle player commands or interactions
    -- Example: Using a recycling facility
    concommand.Add("industrial_recycle", function(player, cmd, args)
        local wasteType = args[1]
        local qty = tonumber(args[2]) or 1
        RecycleWaste(player, wasteType, qty)
    end)
end
```